I have been trying out the Hibernator plugin 0.9.6 in Eclipse 3m3 and to the most part have been successful. I used middlegen to generate the java and mapping files, tweaked the latter to change primitive types to java types and successfully ran some queries.
However, some of the table mappings are complicated...
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="com.landg.clex.hibernate.Tia00570"
table="TIA00570"
schema="CLEX"
>
<id
name="claimCaseNumber"
type="java.lang.Integer"
column="CLAIM_CASE_NUMBER"
>
<generator class="assigned" />
</id>
<property
name="claimType"
type="java.lang.String"
column="CLAIM_TYPE"
not-null="true"
length="2"
/>
<property
name="claimCaseStType"
type="java.lang.String"
column="CLAIM_CASE_ST_TYPE"
not-null="true"
length="2"
/>
<property
name="manualInputInd"
type="java.lang.String"
column="MANUAL_INPUT_IND"
not-null="true"
length="1"
/>
<property
name="createTimestamp"
type="java.sql.Timestamp"
column="CREATE_TIMESTAMP"
not-null="true"
length="26"
/>
<property
name="salary"
type="java.math.BigDecimal"
column="SALARY"
length="15"
/>
<property
name="occupationType"
type="java.lang.String"
column="OCCUPATION_TYPE"
length="2"
/>
<property
name="persId"
type="java.lang.String"
column="PERS_ID"
length="9"
/>
<property
name="logonId"
type="java.lang.String"
column="LOGON_ID"
length="7"
/>
<property
name="othContractInd"
type="java.lang.String"
column="OTH_CONTRACT_IND"
length="1"
/>
<property
name="othMatCntrInd"
type="java.lang.String"
column="OTH_MAT_CNTR_IND"
length="1"
/>
<property
name="clmPackDespdInd"
type="java.lang.String"
column="CLM_PACK_DESPD_IND"
not-null="true"
length="1"
/>
<property
name="maintUserId"
type="java.lang.String"
column="MAINT_USER_ID"
not-null="true"
length="7"
/>
<!-- associations -->
<!-- bi-directional one-to-many association to Tia00602 -->
<set
name="tia00602s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00602"
/>
</set>
<!-- bi-directional one-to-many association to Tia00590 -->
<set
name="tia00590s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00590"
/>
</set>
<!-- bi-directional one-to-many association to Tia00591 -->
<set
name="tia00591s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00591"
/>
</set>
<!-- bi-directional one-to-many association to Tia00584 -->
<set
name="tia00584s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00584"
/>
</set>
<!-- bi-directional one-to-many association to Tia00571 -->
<set
name="tia00571s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00571"
/>
</set>
<!-- bi-directional one-to-many association to Tia00597 -->
<set
name="tia00597s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00597"
/>
</set>
<!-- bi-directional one-to-many association to Tia00586 -->
<set
name="tia00586s"
lazy="true"
inverse="true"
>
<key>
<column name="CLAIM_CASE_NUMBER" />
</key>
<one-to-many
class="com.landg.clex.hibernate.Tia00586"
/>
</set>
</class>
</hibernate-mapping>
...leading to the following exception...
Code:
"Failed to lazily initialize a collection - no Session"
Reading some of the postings on the Hibernate forum suggests that this is due to the session being closed prematurely when lazy loaded collections are being used, so the subsequent load doesn't have a session to use.
Is this a problem with Hibernator?
Also, is there any plans to update the plugin to use Hibernate 2.1.1 in the near future?
Best regards,
Chris