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?