Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0.2
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.tietoenator.dk.lub.integrationlayer.misc.UploadedFileBean"
table="UPLOADED_FILE"
proxy="com.tietoenator.dk.lub.integrationlayer.misc.UploadedFileBean"
>
<id
name="id"
column="ID"
type="long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UploadedFileBean.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="name"
type="string"
update="true"
insert="true"
column="NAME"
length="255"
not-null="true"
unique="false"
/>
<property
name="file"
type="blob"
update="true"
insert="true"
column="FILE"
not-null="false"
unique="false"
/>
<many-to-one
name="user"
class="com.tietoenator.dk.lub.integrationlayer.user.UserBean"
cascade="none"
outer-join="auto"
update="true"
insert="true"
foreign-key="UserUplFile"
column="USER_ID"
not-null="false"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UploadedFileBean.xml
containing the additional properties and place it in your merge dir.
-->
</class>
<query name="getUploadedFileByIdAndUserId"><![CDATA[
from com.tietoenator.dk.lub.integrationlayer.misc.UploadedFileBean uploadedFileBean where uploadedFileBean.id = :id and (uploadedFileBean.user = :userId or uploadedFileBean.user is NULL)
]]></query>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="com.tietoenator.dk.lub.integrationlayer.educationregistration.CheckListItemStatusBean"
table="CHECK_LIST_ITEM_STATUS"
proxy="com.tietoenator.dk.lub.integrationlayer.educationregistration.CheckListItemStatusBean"
>
<id
name="id"
column="ID"
type="long"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-CheckListItemStatusBean.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="done"
type="short"
update="true"
insert="true"
column="CHECKED"
not-null="true"
unique="false"
/>
<many-to-one
name="checklistItemBean"
class="com.tietoenator.dk.lub.integrationlayer.educationadministration.goaldescription.ChecklistItemBean"
cascade="none"
outer-join="auto"
update="true"
insert="true"
foreign-key="ChkLiItemChkLi"
column="CHECK_LIST_ITEM_ID"
not-null="true"
/>
<many-to-one
name="uploadedFileBean"
class="com.tietoenator.dk.lub.integrationlayer.misc.UploadedFileBean"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
foreign-key="UpFileChkLiItem"
column="UPLOADED_FILE_ID"
not-null="false"
/>
<many-to-one
name="checkListStatus"
class="com.tietoenator.dk.lub.integrationlayer.educationregistration.CheckListStatusBean"
cascade="none"
outer-join="auto"
update="true"
insert="true"
foreign-key="ChkliStCheLiItSt"
column="CHECKLIST_STATUS_ID"
not-null="true"
/>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-CheckListItemStatusBean.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
My CheckListItemStatusBean has a reference to a UploadedFileBean.
When I try to update the CheckListItemStatusBean with a new UploadedFileBean a few times I get a OutOfMemory error.
I can see that for every time a update with a new UploadedFileBean the used memory in my tomcat i increasing.
in my CheckListItemStatusBean I have this method that is used to save the UploadedFileBean. The StoredDocument is just a valueobject.
/**
* @param doc
*/
public void setStoredDocument(StoredDocument doc) {
try {
if (doc == null) {
setUploadedFileBean(null);
} else {
UploadedFileBean uploadedFileBean = new UploadedFileBean();
uploadedFileBean.setName(doc.getFilename());
uploadedFileBean.setFile(Hibernate.createBlob(doc.getFiledata()));
if (doc.getUserId() != null) {
UserBean userBean = new UserBean();
userBean.setId(doc.getUserId());
uploadedFileBean.setUser(userBean);
}
setUploadedFileBean(uploadedFileBean);
}
} catch (Exception e) {
e.printStackTrace();
}
}