I have a User class that has @Embedded a class Profile. How can I give the instances of Profile a reference to their owner the User class?
@Entity
class User imp
Refer to the official documentation ,section 2.4.3.4. , http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/ , you can use @org.hibernate.annotations.Parent
to give the Profile object a back-pointer to its owning User object and implement the getter of the user object .
@Embeddable
class Profile implements Serializable {
@org.hibernate.annotations.Parent
User user; // how to make this work?
setURL(String url) {
if (user.active() ) { // for this kind of usage
// do something
}
}
User getUser(){
return this.user;
}
// .. other properties ..
}