The title is quite self explanatory. I have a User class(abstract) which has 2 sublcasses: UserCore(concrete) and UserRole(abstract). UserRole has itself a few more subclasses. The problem lies in User which has no attributes and I want It to stay that way. I've been having a large number of excepcions but, if I'm right, everything comes to User's mapping.
The problem is that if I annotate it as Entity, it has no id. I wont be moving UserCore's and UserRole's id to their superclass since that would not be right. Otherwise, any reference to User in another mapped Entity in my model will cause an exception since User is an unknown entity. I have been stuck with this for long enough but did not find any suiting answer.
Any hints will be appreciated. Thanks in advance!
Thanks for the replies. Well, i knew that moving the id up to the superclass was an option to make it work. I had a reason for not moving the ids up in the hierarchy, which I cant remember now. Neither the MappedSuperclass or leaving the abstract class unmapped wont work with a problem of Unknown entity wherever another entity holds reference of a User.
Do you think that there is no other choice when mapping a hierarchy like this with no attributes at the top of it?
Thanks, once again.
Joined: Oct 01, 2007
An option outside of JPA, using EclipseLink could be to use define an interface for User to use in the references and map to the User interface using a VariableOneToOne mapping.