-->
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: Is there an insertion query ref? (similar to loader)
PostPosted: Fri Mar 11, 2005 6:55 pm 
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?

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 7:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
isn't this just a id-generator?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 8:14 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Yes, this is an Id generator. However, the id needs to be within a joined-subclass ( see the mapping for Application). Unless I misunderstood, I believe Hibernate does not supported that.


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.