I have been debugging Hibernate logs to see if anything obvious comes out
Code:
=[DEBUG] 12:57:32 SQL - select user0_.ID as ID8_0_, registrati1_.ID as ID6_1_, user0_.OBJ_VERSION as OBJ2_8_0_, user0_.FIRSTNAME as FIRSTNAME8_0_, user0_.LASTNAME as LASTNAME8_0_, user0_.USERNAME as USERNAME8_0_, user0_.PASSWORD as PASSWORD8_0_, user0_.ENABLED as ENABLED8_0_, user0_.EMAIL as EMAIL8_0_, user0_.CREATED as CREATED8_0_, registrati1_.OBJ_VERSION as OBJ2_6_1_, registrati1_.URL as URL6_1_, registrati1_.CREATED as CREATED6_1_, registrati1_.USER_ID as USER5_6_1_, registrati1_.TYPE as TYPE6_1_ from USERS user0_ inner join REGISTRATION registrati1_ on user0_.ID=registrati1_.USER_ID where user0_.ID=?
Hibernate: select user0_.ID as ID8_0_, registrati1_.ID as ID6_1_, user0_.OBJ_VERSION as OBJ2_8_0_, user0_.FIRSTNAME as FIRSTNAME8_0_, user0_.LASTNAME as LASTNAME8_0_, user0_.USERNAME as USERNAME8_0_, user0_.PASSWORD as PASSWORD8_0_, user0_.ENABLED as ENABLED8_0_, user0_.EMAIL as EMAIL8_0_, user0_.CREATED as CREATED8_0_, registrati1_.OBJ_VERSION as OBJ2_6_1_, registrati1_.URL as URL6_1_, registrati1_.CREATED as CREATED6_1_, registrati1_.USER_ID as USER5_6_1_, registrati1_.TYPE as TYPE6_1_ from USERS user0_ inner join REGISTRATION registrati1_ on user0_.ID=registrati1_.USER_ID where user0_.ID=?
=[DEBUG] 12:57:32 AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
=[DEBUG] 12:57:32 Loader - result row: EntityKey[com.model.User#1], EntityKey[com.model.Registration#1]
=[DEBUG] 12:57:32 AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
=[DEBUG] 12:57:32 AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
=[DEBUG] 12:57:32 StatefulPersistenceContext - initializing non-lazy collections
As you can see it is issuing the right SQL and loading all the properties of the user and registration class in one go. But then it is not populating the registration object. I just cannot understand why?