Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0rc1
Mapping documents:
Document
Code:
<hibernate-mapping package="com.llic.business">
<class name="Document" table="Document" polymorphism="implicit">
<id name="id" column="documentid">
<generator class="native" />
</id>
<property name="contentMgrUniqueKey" column="contentMgrUniqueKey" type="string" not-null="true" />
<property name="dateReceived" column="DATERECEIVED" type="java.util.Date" not-null="true" />
<property name="scanPacketNumber" column="packetnumber" type="string" />
<many-to-one name="policyNumber" column="policyNumberId" class="PolicyNumber" cascade="save-update"/>
</class>
</hibernate-mapping>
Application
Code:
<hibernate-mapping package="com.llic.business" >
<joined-subclass name="Application" extends="Document" table="Application" >
<key column="DocumentID"/>
<property name="applicationId" column="applicationid" type="java.lang.Long" not-null="true"/>
<property name="policyDate" column="policydate" type="java.util.Date" not-null="false"/>
<property name="applicationDate" column="applicationDate" type="java.util.Date" not-null="false"/>
<set name="appEntityRoles" table="APPENTITYROLE" inverse="true" lazy="false" cascade="all">
<key column="applicationId" property-ref="applicationId"/>
<one-to-many class="com.llic.business.ApplicationEntityRole"/>
</set>
</joined-subclass>
</hibernate-mapping>
ApplicationEntityRole
Code:
<hibernate-mapping package="com.llic.business" >
<class name="ApplicationEntityRole" table="AppEntityRole" >
<id name="id" column="appEntityRoleId" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="entityRoleSubType" column="entityRoleSubTypeId" type="java.lang.Long" not-null="true"/>
<property name="entityId" column="entityId" type="java.lang.Long" not-null="true"/>
</class>
</hibernate-mapping>
Name and version of the database you are using:
DB2 8.2 UDB
Database primary keys
Document.DocumentID
Application.ApplicationID
ApplicationEntityRole.ApplicationEntityRoleID
Database foreign keys
Application.DocumentID -> Document.DocumentID
ApplicatoinEntityRole.ApplicationID -> Application.ApplicationID
In the new 3.0 hibernate, there is a <loader query-ref=""/> tag.
In the above diagram, the legacy database requires that applicationId be the primary key for the applicaition table. In our object model we do not care about the applicationId since an application can never exist without a document. What I would like to know is the following.
Is there a tag (or some simple defininition) similar to loader in the following way
<inserter query-ref="applicationId"/>
<sql-query name="applicationId">
<return alias="id" class="java.lang.Long"/>
Select IDENTITY_VAL_LOCAL() as id
</sql-query>
The semantics would be the following.
1. Application is about to be persisted
2. The sql query is executed, inserting the next identity value from db2 into the applicationId property
3. Applicaiton is persisted
4. All ApplicationEntityRoles are persisted with the applicationId from the previous select.
Steps 3 and 4 are currently executed, is there a way to add steps 1 and 2 in version 3.0?
Thanks,
Todd