Having the model
{code:java} @Entity(name = "Client") public static class Client {
@Id @GeneratedValue private Long id;
private String name;
@Embedded private Log log = new Log();
public Long getId() { return id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public void setId(Long id) { this.id = id; } }
@Entity(name = "User") @Table(name = "`User`") public static class User { @Id @GeneratedValue private Long id;
@Column(length = 120, nullable = false) private String name;
@ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "`idClient`") private Client client;
public Long getId() { return id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Client getClient() { return client; }
public void setClient(Client client) { this.client = client; } }
@Embeddable public static class Log { @Column(name = "`creationDate`", nullable = false) private OffsetDateTime creationDate;
public OffsetDateTime getCreationDate() { return creationDate; }
public void setCreationDate(OffsetDateTime creationDate) { this.creationDate = creationDate; } } {code}
the following test
{code:java} @Test public void load() { inTransaction( session -> { User user = session.find( User.class, userId ); } ); } {code}
causes a
{code:java} org.hibernate.PropertyValueException: not-null property references a null or transient value : Client.log.creationDate
{code}
|
|