-->
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: Problem loading inherited Collections.
PostPosted: Thu Jun 29, 2006 4:26 pm 
Newbie

Joined: Thu Jun 15, 2006 5:58 pm
Posts: 18
Hibernate 3.1.3 PsotgreSQL
Company.hbm

<set name="commissions" batch-size = "20" outer-join = "true" cascade="all, delete-orphan" >
<key column="company_id"/>
<one-to-many class="CompanyCommissions"/>
</set>

CompanyCommissions.hbm
<many-to-one name= "company" column = "company_id" cascade="none" not-null="true"/>
<property name="planType" column = "plan_type"/>
<set name="commissiondetails" batch-size = "20" cascade="all, delete-orphan" inverse = "false" >
<key column="commission_id"/>
<one-to-many class="CompanyCommissionDetails"/>
</set>

CompanyCommissionDetails.hbm

<hibernate-mapping>
<class name="CompanyCommissionDetails" table="tdat_company_commission_details">
<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="companyCommissionDetailId" type="long" unsaved-value="0">
<column name="comp_commission_detail_id" sql-type="serial" not-null="true"/>
<generator class="sequence">
<param name="sequence">tdat_company_commission_details_comp_commission_detail_id_seq</param>
</generator>
</id>
<many-to-one name= "commission" column="commission_id" cascade="none" not-null="true" />
<property name= "rateType" column="rate_type"/>
<property name= "value"/>
<property name= "endRate" column="end_rate"/>
</class>
</hibernate-mapping>


Java Code:

cc = (Company)sess.load(Company.class,cc.getCompanyId());
Hibernate.initialize(cc);
if(cc.getCommissions().size() >= 1){
commissions = cc.getCommissions();
for(Iterator i = commissions.iterator(); i.hasNext();){
CompanyCommissions companycommission = (CompanyCommissions) i.next();
if(companycommission.getPlanType() == 0){
details = companycommission.getCommissiondetails();
System.out.println(details.size());
for(Iterator ii = details.iterator(); ii.hasNext();){
Vector rowData = new Vector();
System.out.println("CHECK1");
CompanyCommissionDetails commissiondetails = (CompanyCommissionDetails) ii.next();
if(commissiondetails.getRateType() == 0) { // hourly rate
rowData.add(commissiondetails.getEndRate());
rowData.add(commissiondetails.getValue());
rateModel.addRow(rowData);
System.out.println("CHECK2");
}
else if(commissiondetails.getRateType() == 1){
rowData.add(commissiondetails.getEndRate());
rowData.add(commissiondetails.getValue());
salesModel.addRow(rowData);
}
}
rateModel.fireTableDataChanged();
salesModel.fireTableDataChanged();
}


I have a company object which has set of companycommissions and each companycommissions can have multiple companycommission details.

When I load the company object, I could set my companycommission set having values but the companycommissiondetails set within my commissions is empty.

I am struggling with this problem. Could some one tell me if my mapping file has got any problem. Why is my commissiondetials collection not getting loaded when I access my company object. When I debugged, my companycommissions set is empty.


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.