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: