how to persist an object of a subclass from an existing super class entity object?
Joined: Sep 22, 2009
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 ?
Joined: Oct 01, 2007
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