This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hello, i have a user entity which inherits from collaborator entity, and i use @Inheritance(strategy = InheritanceType.JOINED) in the Collaborator entity.
I do not find the way to persist a user entity that belongs to an existing collaborator,
i can find a collaborator by em.findById(2);
but how to associate a new user object to this collaborator object ?
If you User "has a" Collaborator, then you simply set it.
But you seem to be confused about inheritance wanting to make a new User "become" a Collaborator? If so, then you should not be using inheritance, but have User have a OneToOne relationship to Collaborator.
hello, thak you for your help,
but i am not confused in inheritance,
User "is a" Collaborator, so i can not simply set it.
so, how i will set it in this situation?
I do not find the way to persist a user entity that belongs to an existing collaborator, I can add a user object and it results to 2 new created rows in the data base but what i want to do is to add only a user object and not a new collaborator.
I can find a collaborator by Collaborator clbr=em.findById(2);
and i want to add a user that its collaborator is clbr but how to associate the new user object to this collaborator object ?
Below my entities