Hibernates stores all properties that declare a type that implements Serializable
.
But the type of your days
property is a Set
, which does not extend Serializable
. To store your set as serialized value you will need to declare a set class which implements Serializable
- like most do. For example HashSet
:
@Entity
public class SomeEntity {
private HashSet<DayOfWeek> days;
}
You don't need any further annotations. This works for Enum
and all other serializable elements.
But for a set of enums exists another option: Use an EnumSet, which stores the values into an integer column (every enum value is exactly one bit). See my answer here: JPA map collection of Enums