Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
The table UCAPSchool has three entries in which the foreign key, ApplicantID, equals 60. I would like the code listed below to pull these three entries. Unfortunately, what the program actually does is to pull one of these entries three times.
Any ideas would be much appreciated.
Hibernate version: 2.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="edu.ucop.ucap.daos">
<class name="School" table="UCAPSchool">
<id
column="ApplicantID"
name="ApplicantID"
type="string"
>
<generator class="assigned" />
</id>
<property
column="SchoolID"
length ="10"
name="SchoolID"
not-null="false"
type="string"
/>
<property
column="SchoolEndMM"
length="2"
name="SchoolEndMM"
not-null="false"
type="string"
/>
<property
column="IsHSSpecOther"
length="1"
name="IsHSSpecOther"
not-null="false"
type="string"
/>
<property
column="IsHSSpecYearRound"
length="1"
name="IsHSSpecYearRound"
not-null="false"
type="string"
/>
<property
column="IsHSSpecMagnet"
length="1"
name="IsHSSpecMagnet"
not-null="false"
type="string"
/>
<property
column="HSDiplomaDateYYYY"
length="4"
name="HSDiplomaDateYYYY"
not-null="false"
type="string"
/>
<property
column="SchoolEndYYYY"
length="4"
name="SchoolEndYYYY"
not-null="false"
type="string"
/>
<property
column="IsHSSpecAcademy"
length="1"
name="IsHSSpecAcademy"
not-null="false"
type="string"
/>
<property
column="HSSpecYearRoundTrack"
length="16"
name="HSSpecYearRoundTrack"
not-null="false"
type="string"
/>
<property
column="SchoolBeginMM"
length="2"
name="SchoolBeginMM"
not-null="false"
type="string"
/>
<property
column="GradeSystem"
length="2"
name="GradeSystem"
not-null="false"
type="string"
/>
<property
column="HSDiploma"
length="32"
name="HSDiploma"
not-null="false"
type="string"
/>
<property
column="SchoolType"
length="1"
name="SchoolType"
not-null="false"
type="string"
/>
<property
column="SchoolState"
length="2"
name="SchoolState"
not-null="false"
type="string"
/>
<property
column="UCAPSchoolCode"
length="6"
name="UCAPSchoolCode"
not-null="false"
type="string"
/>
<property
column="IsHSSpecOtherDesc"
length="16"
name="IsHSSpecOtherDesc"
not-null="false"
type="string"
/>
<property
column="HSDiplomaDateMM"
length="2"
name="HSDiplomaDateMM"
not-null="false"
type="string"
/>
<property
column="SchoolInfoID"
length="10"
name="SchoolInfoID"
not-null="false"
type="string"
/>
<property
column="IsHSTermTypeTri"
length="1"
name="IsHSTermTypeTri"
not-null="false"
type="string"
/>
<property
column="IsGraduationHS"
length="1"
name="IsGraduationHS"
not-null="false"
type="string"
/>
<property
column="IsHSTermTypeFull"
length="1"
name="IsHSTermTypeFull"
not-null="false"
type="string"
/>
<property
column="IsLastEnrolledHS"
length="1"
name="IsLastEnrolledHS"
not-null="false"
type="string"
/>
<property
column="SchoolCountryOther"
length="32"
name="SchoolCountryOther"
not-null="false"
type="string"
/>
<property
column="SchoolName"
length="32"
name="SchoolName"
not-null="false"
type="string"
/>
<property
column="HSTermSystemCode"
length="1"
name="HSTermSystemCode"
not-null="false"
type="string"
/>
<property
column="SchoolCity"
length="32"
name="SchoolCity"
not-null="false"
type="string"
/>
<property
column="SchoolBeginYYYY"
length="4"
name="SchoolBeginYYYY"
not-null="false"
type="string"
/>
<property
column="SchoolCountryCode"
length="3"
name="SchoolCountryCode"
not-null="false"
type="string"
/>
<property
column="IsHSTermTypeSem"
length="1"
name="IsHSTermTypeSem"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
List all = session.find("from School as sch where sch.ApplicantID = ?", "60", Hibernate.STRING);
for (ListIterator iter = all.listIterator() ;
iter.hasNext() ; ) {
School school = (School)iter.next();
System.out.println(school.getSchoolName());
}
Full stack trace of any exception that occurs:
Name and version of the database you are using: Sybase 12.5
The generated SQL (show_sql=true):
Hibernate: select school0_.ApplicantID as Applican1_, school0_.SchoolID as SchoolID, school0_.SchoolEndMM as SchoolEn3_, school0_.IsHSSpecOther as IsHSSpec4_, school0_.IsHSSpecYearRound as IsHSSpec5_, school0_.IsHSSpecMagnet as IsHSSpec6_, school0_.HSDiplomaDateYYYY as HSDiplom7_, school0_.SchoolEndYYYY as SchoolEn8_, school0_.IsHSSpecAcademy as IsHSSpec9_, school0_.HSSpecYearRoundTrack as HSSpecY10_, school0_.SchoolBeginMM as SchoolB11_, school0_.GradeSystem as GradeSy12_, school0_.HSDiploma as HSDiploma, school0_.SchoolType as SchoolType, school0_.SchoolState as SchoolS15_, school0_.UCAPSchoolCode as UCAPSch16_, school0_.IsHSSpecOtherDesc as IsHSSpe17_, school0_.HSDiplomaDateMM as HSDiplo18_, school0_.SchoolInfoID as SchoolI19_, school0_.IsHSTermTypeTri as IsHSTer20_, school0_.IsGraduationHS as IsGradu21_, school0_.IsHSTermTypeFull as IsHSTer22_, school0_.IsLastEnrolledHS as IsLastE23_, school0_.SchoolCountryOther as SchoolC24_, school0_.SchoolName as SchoolName, school0_.HSTermSystemCode as HSTermS26_, school0_.SchoolCity as SchoolCity, school0_.SchoolBeginYYYY as SchoolB28_, school0_.SchoolCountryCode as SchoolC29_, school0_.IsHSTermTypeSem as IsHSTer30_ from UCAPSchool school0_ where (school0_.ApplicantID=? )
Debug level Hibernate log excerpt: