erzeugt
Code: Select all
@Entity
public class DemoEntity {
@EmbeddedId
private Id id = new Id(UUID.randomUUID());
@Embeddable
public static record Id(@Basic UUID value) implements Serializable {}
}
< /code>
Aber wenn ich versuche, es mit Hibernate 5.4.32 zu bestehen, erhalte ich den folgenden Fehler: < /p>
org.hibernate.InstantiationException: No default constructor for entity: : com.example.demo.DemoEntity$Id
at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:85) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.tuple.component.AbstractComponentTuplizer.instantiate(AbstractComponentTuplizer.java:84) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
...
Das gleiche passiert mit Nicht-ID-Feldern und @embeded :
Code: Select all
@Embedded
private Thing thing = new Thing("example");
@Embeddable
public static record Thing(@Basic String value) implements Serializable {}