-->
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: can not join two tables
PostPosted: Fri Oct 13, 2006 1:15 am 
Newbie

Joined: Thu Oct 12, 2006 12:50 am
Posts: 3
Hi,
I faced a problem regarding joining two table using criteria api. Any one pls help me.

1.BbMasterNameplateSet.java

public class BbMasterNameplateSet {

private Integer nmplSetId;

private String nmplSetDesc;


private Set bbNameplates = new HashSet(0);
....IT's set and get method..............

2.BbNameplate.java

public class BbNameplate {

private Integer nmplId;

private Integer prodLineId;

private String nmpl;

private String nmplDesc;

private Integer nmplSetId;

private BbMasterNameplateSet bbMasterNameplateSet;
................. IT's set and get method...............

3.BbMasterNameplateSet..hbm.xml
<hibernate-mapping>
<class name="com.cal.dto.BbMasterNameplateSet" table="bb_master_nameplate_set" schema="dbo" >

<id name="nmplSetId" type="integer">
<column name="nmpl_set_id" precision="9" scale="0" />
<generator class="identity" />

</id>
<property name="nmplSetDesc" type="string">
<column name="nmpl_set_desc" length="60" not-null="true" />
</property>
<set name="bbNameplates" table="bb_nameplate" inverse="true">
<key>
<column name="nmpl_set_id" precision="9" scale="0" />
</key>
<one-to-many class="com.cts.cal.dto.BbNameplate" />
</set>


4.BbNameplate.hbm.xml

<hibernate-mapping>
<class name="com.cts.cal.dto.BbNameplate" table="bb_nameplate" schema="dbo" >

<id name="nmplId" type="integer">
<column name="nmpl_id" precision="9" scale="0" />
<generator class="identity" />
</id>

<property name="prodLineId" type="integer">
<column name="prod_line_id" precision="9" scale="0" />
</property>


<property name="nmpl" type="string">
<column name="nmpl" length="20" not-null="true" />
</property>
<property name="nmplDesc" type="string">
<column name="nmpl_desc" length="30" />
</property>
<property name="nmplSetId" type="integer" insert="false" >
<column name="nmpl_set_id" precision="9" scale="0" />
</property>


I think problem in hbm.xml

When I run the program.The program is like this..........

BbMasterNameplateSetHome bbMasterNameplateSetHome = new BbMasterNameplateSetHome();
List arrayList = new ArrayList();
HashMap nmplSet = new HashMap();

BbMasterNameplateSet bbMasterNameplateSet = new BbMasterNameplateSet();


bbMasterNameplateSet.setNmplSetId(new Integer( nameplateSetId));

arrayList = bbMasterNameplateSetHome.findByExample(bbMasterNameplateSet);



for(int count = 0 ; count<arrayList.size(); count++)
{
//nmplSet.put(((BbNameplate) arrayList.get(count)).getNmplId(),((BbNameplate) arrayList.get(count)).getNmplSetId());
nmplSet.put(((BbNameplate) arrayList.get(count)).getNmplId(),((BbNameplate) arrayList.get(count)).getBbMasterNameplateSet().getNmplSetId());

}


return nmplSet;
}


then hibernate form the query but shows error.The error is like this


Hibernate: select this_.nmpl_set_id as nmpl1_0_, this_.nmpl_set_desc as nmpl2_0_0_, this_.audit_insert_dt as audit3_0_0_, this_.audit_insert_pgm as audit4_0_0_, this_.audit_insert_login as audit5_0_0_, this_.audit_update_dt as audit6_0_0_, this_.audit_update_pgm as audit7_0_0_, this_.audit_update_login as audit8_0_0_ from dbo.bb_master_nameplate_set this_ where (1=1)
Exception in thread "main" java.lang.ClassCastException: com.cts.cal.dto.BbMasterNameplateSet
at com.cts.cal.businessobjects.NamePlateManager.retieveNamePlateSet(NamePlateManager.java:59)
at com.test.Tester.main(Tester.java:16)


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.