openjpa - Hibernate - Need annotations for one to zero or one -


i'm trying return admin if id not found in user table

select * /*both admin & user data */  admin,user  admin.id = user.id 

i have both admin & user (which use other purposes) pojos. include user within admin , use @primarykeycolumnjoin & @onetoone (optional=false).

openjpa handles correctly whereas hibernate gives npe. know how hibernate?

i know doesn't answer question directly, consider changing model. "admin" role assigned user rather distinct entity, allowing have user play different roles in different scenarios.

@entity @table(name = "user") public class user {     @elementcollection     @collectiontable(name = "user_role", joincolumns = @joincolumn(name = "user_id"))     @column(name = "role")     private final set<role> roles = new hashset<>(); }  public enum role {     general, admin, root } 

Comments