-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Inserter tag? Similar to loader, but on insertion.
PostPosted: Sat Mar 12, 2005 11:31 am 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
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?

NOTE:This is simply an id with generator type "native". However, this functionality needs to be on Application which is a joined-sublcass! I beleive there is currently no way to specify an id within a joined subclass. Is it possible create the same functionality using something other than the id tag since it is not available?


Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 5:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Don't post the same stuff twice, won't get you more answers.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 6:39 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Sorry, I just assumed that when my post was read, no one noticed that the class was a joined subclass, and dismissed the posting. I have been searching for an answer for a week, and we're beginning to lag behind on the project due to this issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.