-->
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: one-to-many list mapping without a index field
PostPosted: Thu Dec 02, 2004 4:11 pm 
Newbie

Joined: Thu Dec 02, 2004 3:51 pm
Posts: 8
Hibernate version:2.0.3

Here are the mapping documents for my two objects.
The classes themselves are simple POJO's with a public getter and setter for each field.

Person Mapping file
Code:
<class name="tapestry.demo.domain.Person" table="PERS" schema="ANSWR">
        <id name="persSeqId" column="PERS_SEQ_ID" type="double">
            <generator class="increment"/>
        </id>
        <property name="lastName" column="SBMD_LAST_NME"      type="string"/>
        <property name="firstName" column="SBMD_FIRST_NME" type="string"/>
<list name="contacts" lazy="true">
            <key column="PERS_SEQ_ID"/>
            <index column="CNTC_SEQ_ID"/>
            <one-to-many class="tapestry.demo.domain.Contact"/>
        </list>
</class>

Contact Mapping file
Code:

    <class name="tapestry.demo.domain.Contact" table="HA_CNTC" schema="HLP_ANSWR">
        <id name="contactSeqId" column="CNTC_SEQ_ID" type="double">
            <generator class="increment"/>
        </id>

        <property name="persSeqId" column="PERS_SEQ_ID" type="double"/>
        <property name="contactDate" column="SBMD_CALL_DTE" type="string"/>
        <property name="contactTime" column="SBMD_CALL_TME" type="string"/>
</class>




Here is the code being execute (Again, it is coming back with a successfull return of all matching person objects)

Code:
List people = null;
        if (session != null) {
            try {
                people = session.find("from Person as p where p.lastName = ?", lastName, Hibernate.STRING);
            } catch (HibernateException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
            }
        }
       



I am not getting any stack traces in my Log4J log, but I am also not finding any matching contact objects where I can see in the DB that they do exist. When i look at the debugger and evaluate a Person object inside the list that returns from the above code, looking at the contacts collection shows me this message

Quote:
All elements in visible range are null


The problems seems to be with how I am specifiying the index field. Becuase when I look at what the debugger says in the size of the contacts colletion in the Person object, the size is always 1 greater than the value of the field I defined in the index column parameter.

Issue is that I can't change these tables to add a index field for hibernate to use, and I am hoping to avoid doing sorted results as a TreeSet so that I don't have to deal with the comparator's.

Is there anyway to return a list object through the one-to-many mapping, without providing a index column?

And what exactly does Hibernate need the index column for?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 02, 2004 11:21 pm 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
Hi,

try it with set again


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.