I have an entity called Document and it has a one-to-many relationship with entity Version. Version has a field PDF which contains blobs. I wrote the following mapping for Document:
Code:
<class name="Document" table="Document" discriminator-value="DOC" lazy="false">
<id name="id" type="long" column="ID">
<generator class="increment" />
</id>
<set name="versions" cascade="all">
<key column="DOCUMENT_ID" />
<one-to-many class="Version" />
</set>
</class>
And Version has the following mapping:
Code:
<class name="Version" table="VERSION" lazy="true">
<id name="id" type="long" column="ID" >
<generator class="increment" />
</id>
<property name="versionedDoc" column="pdf" type="com.company.pen.hibernate.usertypes.BinaryBlobType" />
</class>
I get out of memory exception when I try to fetch documents with their versions. I understand why that happens but how can I rewrite my mapping so that Version is lazily fetched. I thought setting lazy=true on Version was enough but I keep getting the same exception.
Thanks in advance to anyone who can help.
Regards,
Emmanuel