Hi,
I have a class named Parent as follows
@Entity
public class Parent {
@Id
@GeneratedValue
private Integer id;
@Embedded
private Message message;
}
DBA (minimal OOP knowledge) has designed both Parent and Message properties in PARENT table. Message class behaves like a @OneToOne mapping because, at some cases, according to business requirement, it has:
- Independent lifespan of the owning entity instance (Parent class)
But @Embeddable class, by default, share the same table of the owning entity (Another approach could be use a @SecondaryTable). So, i have a @Embeddable class - share the the same table of the owning entity - that behaves like a @OneToOne - according to business requirement.
Sometimes i want to update a Parent object but I DO NOT WANT to update a Message @Embedded property due business requirement (see above). When i retrieve my updateable Parent object, its message property will be null. Then Message properties will be null in database because its lifespan is bound to the lifespan of the owning entity instance (Parent). So how can i avoid @Embedded Message property to be updatable ?
Regards,