-->
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: Help with mapping a List
PostPosted: Mon Oct 18, 2004 9:35 am 
Newbie

Joined: Mon Sep 13, 2004 4:00 pm
Posts: 15
Location: WI
We are moving our application from OJB to Hibernate. I am not sure how to map a particular relationship. A client contains 1 or many client groups. Each client group is a part of only one client.

The ClientGroup table contains the client id of it's parent Client.

I have been looking through the documentation and am not sure the best way to map this. I considered a List, but didn't want to add the column to the database if I could avoid it. I was thinking maybe an idbag? Any other suggestions?

Hibernate version:
2.1
Mapping documents:
Code:
<hibernate-mapping schema="ADMSTDDE">
    <class name="Client" table="DEXA010T">
        <id column="CLIENT_ID" name="id" type="string">
            <generator class="assigned"/>
        </id>
        <property column="NAME" name="name" type="string"/>
        <property column="last_name" name="lastClientName" type="string"/>
        <property column="LAST_NAME_DT" name="nameUpdateDate" type="date"/>
         ......
    </class>
    <class name="ClientGroup" table="DEXA020T">
        <id column="CLIENT_GROUP_ID" name="id" type="integer">
            <generator class="sequence"/>
        </id>
        <property column="CLIENT_ID" name="clientId" type="string"/>
        <property column="NAME" name="name" type="string"/>
        <property column="last_name" name="lastOrganizationName" type="string"/>
        .......
    </class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Here is the current code for a client and a client group. This could be changed if it makes the relation easier to map, but this is how it currently is:
Client
Code:
public class Client extends SimpleBean {
   
   public static final int ID_LENGTH = 15;
   
   private String id = null;
   private String name = null;
        ....
   private List clientGroups = new ArrayList();
        ....
}

ClientGroup
Code:
public class ClientGroup extends SimpleBean {
   
   protected int id;
   private Client client = null;
   private String name = null;
        ....
}

Full stack trace of any exception that occurs:
.
Name and version of the database you are using:
DB2
The generated SQL (show_sql=true):
...
Debug level Hibernate log excerpt:
...


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.