-->
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: reference non prime key ??
PostPosted: Tue Nov 22, 2005 6:26 am 
Newbie

Joined: Tue Nov 15, 2005 7:20 am
Posts: 17
I'm a newbie at hibernate and don't seem to understand the doc.


I'm trying to do a simple thing i guess

i have two tables/classes containing following simple items



I've tried several combinations of Properties and keys mappings but do not seem to understand the XML mapping structure
can anyone please help me with a good mapping file ?

<class entity-name="info" table="InFO" node="info">
<id name="id" node="@id" column="id" type="long" >
<generator class="native" />
</id>
<many-to-one name="ARef" node="@A" column="A" property-ref="AA" entity-name="REFS" embed-xml="true" insert="true" cascade="all" />

</class>
<class entity-name="REFS" table="REFS" dynamic-insert="true">
<id name="ID" node="@nodIexID" column="SID" type="long" ><generator class="native" /></id>
<property name="AA" node="@AA" column="AAA" not-null="false" type="string" length="50" />
</class>



I want to be able to refference the correct REFS FROM THE InFo table
as for instance select * from INFO,REFS if AREF is NOT NULL (where AA == AREF)
I can not declare AA a primary key , since the final structure should look more like the following




<class entity-name="info" table="InFO" node="info">
<id name="id" node="@id" column="id" type="long" >
<generator class="native" />
</id>
<many-to-one name="ARef" node="@A" column="A" property-ref="AA" entity-name="REFS" embed-xml="true" insert="true" cascade="all" />
<many-to-one name="BRef" node="@B" column="B" property-ref="BB" entity-name="REFS" embed-xml="true" insert="true" cascade="all" />
<many-to-one name="CRef" node="@C" column="C" property-ref="CC" entity-name="REFS" embed-xml="true" insert="true" cascade="all" />
<many-to-one name="DRef" node="@D" column="D" property-ref="DD" entity-name="REFS" embed-xml="true" insert="true" cascade="all" />

</class>
<class entity-name="REFS" table="REFS" dynamic-insert="true">
<id name="ID" node="@nodIexID" column="SID" type="long" ><generator class="native" /></id>
<property name="AA" node="@AA" column="AAA" not-null="false" type="string" length="50" />
<property name="BB" node="@BB" column="BBB" not-null="false" type="string" length="10" ></property>
<property name="CC" node="@CC" column="CCC" not-null="false" type="string" length="15" />
<property name="DD" node="@EE" column="DDD" not-null="false" type="string" length="10" />
</class>

In the end I want to be able to refference the correct REFS FROM THE InFo table
as for instance select * from INFO,REFS if AREF is NOT NULL (where AA == AREF)
if BREF is NOT NULL (where BB == BREF)
if CREF is NOT NULL (where CC == CREF)
if DREF is NOT NULL (where DD == CREF)




Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
XML way to go


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.