Well, digging it, I found that Hibernate does not load the relationships, they are lazy for sure, but, the initial query joins the tables anyway, which is bothering me (and will bother the DBA for sure)
Here's the output of em.find(AbstractMedia.class, id)
Code:
select abstractme0_.ID as ID4_4_, abstractme0_.DELETED as DELETED4_4_, abstractme0_.MEDIA_HASH as MEDIA4_4_4_, abstractme0_.FOLDER_ID as FOLDER7_4_4_, abstractme0_.SHARED as SHARED4_4_, abstractme0_.TITLE as TITLE4_4_, abstractme0_1_.CATEGORY_ID as CATEGORY1_5_4_, abstractme0_.FILE_ID as FILE8_4_4_, abstractme0_.CAPABILITY_ID as CAPABILITY9_4_4_, abstractme0_.TYPE as TYPE4_4_, metadatava1_.MEDIA_ID as MEDIA1_6_, metadatava1_.METADATA_ID as METADATA2_6_, metadatava1_.VALUE as VALUE6_, metadata2_.id as id0_0_, metadata2_.KEY_ATTR as KEY2_0_0_, abstractme3_.ID as ID4_1_, abstractme3_.DELETED as DELETED4_1_, abstractme3_.MEDIA_HASH as MEDIA4_4_1_, abstractme3_.FOLDER_ID as FOLDER7_4_1_, abstractme3_.SHARED as SHARED4_1_, abstractme3_.TITLE as TITLE4_1_, abstractme3_1_.CATEGORY_ID as CATEGORY1_5_1_, abstractme3_.FILE_ID as FILE8_4_1_, abstractme3_.CAPABILITY_ID as CAPABILITY9_4_1_, abstractme3_.TYPE as TYPE4_1_, mediafile4_.ID as ID1_2_, mediafile4_.EXTENSION as EXTENSION1_2_, mediafile4_.FILE_NAME as FILE3_1_2_, mediafile4_.MIME_TYPE as MIME4_1_2_, mediafile4_.SIZE as SIZE1_2_, audiocapab5_.MEDIA_CAPABILITY_ID as MEDIA1_2_3_, audiocapab5_.SAMPLE_RATE as SAMPLE1_7_3_ from MEDIA abstractme0_ left outer join MEDIA_CATEGORY abstractme0_1_ on abstractme0_.ID=abstractme0_1_.MEDIA_ID left outer join METADATA_VALUE metadatava1_ on abstractme0_.ID=metadatava1_.MEDIA_ID left outer join METADATA metadata2_ on metadatava1_.METADATA_ID=metadata2_.id left outer join MEDIA abstractme3_ on abstractme0_.FOLDER_ID=abstractme3_.ID left outer join MEDIA_CATEGORY abstractme3_1_ on abstractme3_.ID=abstractme3_1_.MEDIA_ID left outer join MEDIA_FILE mediafile4_ on abstractme3_.FILE_ID=mediafile4_.ID left outer join AUDIO_CAPABILITY audiocapab5_ on abstractme3_.CAPABILITY_ID=audiocapab5_.MEDIA_CAPABILITY_ID left outer join MEDIA_CAPABILITY audiocapab5_1_ on audiocapab5_.MEDIA_CAPABILITY_ID=audiocapab5_1_.MEDIA_CAPABILITY_ID where abstractme0_.ID=10
Regards