You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Embeddable classes must adhere to the requirements specified in Section 2.1 for entities with the exception that embeddable classes are not annotated as Entity. Embeddable classes must be annotated as Embeddable or denoted in the XML descriptor as such.
And section 2.1 says, among other things
The entity class must be a top-level class.
Modelling an embeddable class as a inner class of an entity is sometimes very usefull. For instance, it makes clear where this embeddable belongs. For a top-level class, the naming would need to follow something like MyEntity and MyEntitySomething, whereas using an inner class the embeddable could just be named Something since it is clear where it belongs.
Hibernate actually already supports this, and we are using this approach, but since it is not covered by the spec we are not sure if this is future-proof.
@Entity
public MyEntity {
... other stuff omitted
@Embedded
private Something something
@Embeddable
public static class Something {
}
}
The text was updated successfully, but these errors were encountered:
For embeddables, the current specification says
And section 2.1 says, among other things
Modelling an embeddable class as a inner class of an entity is sometimes very usefull. For instance, it makes clear where this embeddable belongs. For a top-level class, the naming would need to follow something like MyEntity and MyEntitySomething, whereas using an inner class the embeddable could just be named Something since it is clear where it belongs.
Hibernate actually already supports this, and we are using this approach, but since it is not covered by the spec we are not sure if this is future-proof.
The text was updated successfully, but these errors were encountered: