-->
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.  [ 2 posts ] 
Author Message
 Post subject: mapping a table with 2 maps
PostPosted: Mon Apr 26, 2004 5:47 pm 
Newbie

Joined: Mon Apr 26, 2004 5:17 pm
Posts: 13
First I read the reference manual twice but i really have a point where I don't get through. My case is as following:

An Order has Remarks. There are internal and external remarks. the table model looks like this.

ordertable:
orderid
cust...
..
..
primary key: orderid

remarktable:
orderid
remarktype
sequencenumber (line number)
textline
primary key: orderid, remarktype, squencenumber

my java object idea was like this:

orderobject:
int orderid
Customer cust...
...
Map Remarks (key: remarktype, element: remark)

remarkobject:
orderid
remarktype
Map lines (key: lineNumber, element: String)


My hibernate looks like this:

<class name="order">

<map name="Remarks" table="remarks" inverse="true">
<key name="remarktype" column="remarktype"/>
<?????>
// Here i'm getting confused
</????>
</map>

</class>

<class name="remark">
// Here as well. Should a make a class RemarkLines or Remark?
</class>


Whats the hibernate mapping in such a case? Any hints appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 27, 2004 4:32 am 
Newbie

Joined: Mon Apr 26, 2004 5:17 pm
Posts: 13
I'm trying some mappings. And I wanted to know if anybody good give me a hint if I'm on the right way.

Can I right to classes for the same table? or should I drop one?

Code:
<hibernate-mapping package="ch.globus.nglr">
   <class name="NglrRemark" table="NGLR_REMARK">
      <composite-id>
         <key-many-to-one
            class="ch.globus.nglr.NglrHeader"
            column="HEADERID"
            length="10"
            name="headerid"
            not-null="true"
            type="java.lang.Integer"
          />
         <key-property
            column="REMARKTYPE"
            length="1"
            name="remarktype"
            not-null="true"
            type="java.lang.String"
          />
      </composite-id>
      <list
         inverse="true"
         name="Remarklines"
         table="NGLR_REMARK"
      >
         <index column="SEQNBR" type="java.lang.Integer" />
         <one-to-many class="ch.globus.nglr.NglrRemarkLine" />
      </list>
   </class>
   
   <class name="NglrRemarkLine" table="NGLR_REMARK">
      <composite-id>
         <key-many-to-one
            class="ch.globus.nglr.NglrHeader"
            column="HEADERID"
            name="header"
          />
         <key-many-to-one
            class="ch.globus.nglr.NglrRemark"
            column="REMARKTYPE"
            name="remarktype"
          />
         <key-property
            column="SEQNBR"
            length="10"
            name="seqnbr"
            not-null="true"
            type="java.lang.Integer"
          />
      </composite-id>
      <property
         column="TEXT"
         length="72"
         name="text"
         not-null="true"
         type="java.lang.String"
       />
   </class>
</hibernate-mapping>



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