Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hibernate Problem using subselect set

Status
Not open for further replies.

luckydexte

Programmer
Apr 26, 2001
84
US
Hello all,

I am new to Hibernate and I am getting an error that I cannot seem to resolve. Below is the hbm.xml file, the java class, and a little utility to run the code. I am printing the SQL code and when I run it in SQL plus I get the expected results but it will not load when I call my class. Any help would be greatly appreciated.

Note, I have elimated some of the table names to make the code shorter by using @@ where I have taken something out.

hbm.xml file:
<hibernate-mapping>
<class name="@@.IndGeneralSite" table="@@IND_SITE">
<composite-id>
<key-property name="permitNumber"
column="PERMIT_NO" type="java.lang.Integer" />
<key-property name="siteNumber"
column="SITE_NO" type="java.lang.Integer" />
</composite-id>

<set name="patches" order-by="PATCH_NO"
fetch="subselect" mutable="false" >
<key update="false">
<column name="PERMIT_NO" />
<column name="SITE_NO" />
</key>
<one-to-many class="@@.IndGeneralPatch" />
</set>

// A list of other fields omitted
</hibernate-mapping>

.java file
public class IndGeneralSite extends ActionForm {
private Integer permitNumber;
private Integer siteNumber;
private Set patches = new HashSet();

public Integer getPermitNumber() { return permitNumber; }
public Integer getSiteNumber() { return siteNumber; }
public Set getPatches() { return patches; }

public void setPermitNumber(Integer i) {permitNumber=i;}
public void setSiteNumber(Integer i) {siteNumber = i;}
public void setPatches(Set patches) { this.patches = patches; }

Utility to print the hash set (patches)

IndPermitFunctions pf = new IndPermitFunctions();
IndGeneralPermit igp = pf.getPermit("565719");
IndGeneralSite igs = pf.getSite("565719", "2");
HashSet col = new HashSet(igs.getPatches());
Iterator iterator = col.iterator();
while (iterator.hasNext()){ // Does not get into
System.err.print(iterator.next() + "\n ");
}

System.err.println("patches are " + igs.getPatches());

Output:
[7/26/07 ] 3da068ad SystemErr R patches are []

However, when I run the SQL statement it generates I get the expected result. Any ideas? Thanks again.

Brandon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top