-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping where joined-subclass has its own primary key
PostPosted: Tue Mar 01, 2005 10:24 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:
2.1.8
Mapping documents:
NONE
Code between sessionFactory.openSession() and session.close():
NONE
Full stack trace of any exception that occurs:
NONE
Name and version of the database you are using:
DB2 UDB 8.2
The generated SQL (show_sql=true):
NONE
Debug level Hibernate log excerpt:
NONE


Hi all,
I have a question about mapping and I cannot find a good answer to it. I have the following business object structure.

Document

Application extends Document

Application has many ApplicationEntityRoles

In the database I have the following foreign keys


Document --> Primary Key = DocumentID

Application --> Primary Key = ApplicationID. Foreign Key = DocumentID

ApplicationEntityRole --> PrimaryKey = ApplicationEntityRoleID. ForeignKey = ApplicationID.

Now, I have the following mapping.


Code:
<hibernate-mapping package="com.llic.business">
   <class name="Document" table="DOCUMENT">
      <id
         column="DOCUMENTID"
         name="id"
         type="java.lang.Long"
      >
         <generator class="native" />
      </id>

            .....
            <joined-subclass name="Application" table="APPLICATION" extends="Document">
   <!--   <id
         column="APPLICATIONID"
         name="id"
         type="java.lang.Long"
      >
         <generator class="native" />
      </id>-->
      
      <key column="DOCUMENTID"/>

                 ...
                 </joined-subclass>


My question is the following. Is there any way to map the applicationId in hibernate so that it is automatically generated by the identity in DB2? It is needed since the foreign key to ApplicationID is contained within ApplicationEntityRole. I can't change our Schema, since it needs to remain compatible with legacy appliations. Any help would be greatly appreciated.

Thanks,
Todd


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

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.