-->
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.  [ 4 posts ] 
Author Message
 Post subject: Joined Subclass with primary key in legacy database
PostPosted: Mon Mar 07, 2005 3:20 pm 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Hibernate version:
3.0rc1

We are beginning development with Hibernate 3, and I will wait for Spring to release 1.2 with Hibernate 3 support. I have the following object scenario

-> = Excends

#> = Foregin Key to primary key.


Object setup

Application -> Document

Application has many ApplicationEntityRoles


Database setup

Application #> Document (joined sublcass by document id, that part is easy)

ApplicationEntityRole #> Application.

NOTE: Application has is own primary key, and this is required by legacy apps!

Anthony mentioned in his earlier posts that a column and a formula could be used. I've reviewed the documentation, and it is not clear to me how to utilize this. Is there an example somewhere? Also, from my understanding of Hibernate, if I map a Set of AppliationEntityRoles into the Appliation mapping, it will be default use the primary key in Document correct?

Take the following example mappings...

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" />
  </class>
</hibernate-mapping>


Application
Code:
<hibernate-mapping package="com.llic.business" >
   <joined-subclass  name="Application" extends="Document" table="Application" >
   
   <key column="DocumentID"/>
   
<!-- the tables primary key, how would I map this -->
   <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"/>
      <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="entityRoleTypeType" column="entityRoleTypeTypeId" type="java.lang.Long" not-null="true"/>
   
   </class>
   
</hibernate-mapping>





When the sql is generated, won't this join APPENTITYROLE.ApplicationID = Document.DocumentID? I will also have an issue on the insertion of Application. The only solution I can think of is to extend JoinedSubclassEntityPersister, but this just feels like a hack to me. That would take care of the issue of persisting a new Application, but it will not help with joining APPENTITYROLE.ApplicaitonID with DOCUMENT.documentID. Does anyone have any suggestions? I'm stumped and I really need a hand.

Thanks,
Todd


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 2:59 am 
Newbie

Joined: Fri Mar 04, 2005 9:18 am
Posts: 5
Location: Hasselt, Belgium
Hello,

Have you found a solution to your problem as I am facing a similar problem.

Kind Regards,

Niels


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 10:52 am 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
Unfortunately I have not found a solution, no one has responded. I've emailed Anthony directly for some guidance in the right direction. I would like to contribute documentation into the Hibernate documentation as to how to do this once I figure it out. Unfortunately I have not received any response from anyone. I'm assuming that everyone is extremely busing getting ready for the official release of Hibernate 3.0. I'm buying the Hibernate In Action book, even though it's for version 2, it will hopefully give me some insight on this problem, as well as using container managed transactions. If you come across any helpful hints, please post them here.


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

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
I have started another thread with more information provided, hopefully I will receive an answer.

http://forum.hibernate.org/viewtopic.php?t=939857


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.