Hello all,
This post is about property lazy fetching. I'm migrating one of our application from our own persistence system to Hibernate. This app store, transform and process messages between several partners. We are using only one table to store the messages (in a blob field) with their header data. We often need to load only the header data without the message payloads and I'm not sure what is the best way to do that. I've read different things and thought about different scenarios :
1/ Use the lazy property fetching but §19.1.7 of Hibernate documentation don't recommend that. Moreover, I'm prefer not having additionnal buildtime bytecode. 2/ Still in §19.1.7, it is suggested to use projections features of HQL and Criteria queries but I don't understand how to solve my problem with that... 3/ Remove the payload property from the main Entity, create a second second one with only the primary key and the payload, mapped on the same table and make a one-to-one association between these two entities.
Could you help me to understand which one is the best scenario for us or maybe to tell me if I didn't understand something in the lazy property fetching mechanism.
Here is a simplified description of the table :
id (int) : internal message ID, 1 byte, PrimaryKey senderId (string) : message sender id, few bytes receiverId (string) : message receiver id, few bytes document id (string) : business document id, few bytes documentType (string) : type of the document, few bytes documentFormat (string) : format of the document, few bytes payload (blob) : the entire gzipped document, often > 100ko
Thanks for your help
|