Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 15477 invoked from network); 5 Jan 2006 17:16:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Jan 2006 17:16:29 -0000 Received: (qmail 6225 invoked by uid 500); 5 Jan 2006 17:16:28 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 6201 invoked by uid 500); 5 Jan 2006 17:16:26 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 6190 invoked by uid 99); 5 Jan 2006 17:16:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2006 09:16:26 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.34] (HELO brmea-mail-3.sun.com) (192.18.98.34) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2006 09:16:25 -0800 Received: from fe-amer-10.sun.com ([192.18.108.184]) by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id k05HG43F002310 for ; Thu, 5 Jan 2006 10:16:04 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0ISM00K01QK84R00@mail-amer.sun.com> (original mail from Nathan.Maves@Sun.COM) for user-java@ibatis.apache.org; Thu, 05 Jan 2006 10:16:04 -0700 (MST) Received: from [129.147.48.10] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0ISM00BQGQMRJNND@mail-amer.sun.com> for user-java@ibatis.apache.org; Thu, 05 Jan 2006 10:16:04 -0700 (MST) Date: Thu, 05 Jan 2006 10:16:09 -0700 From: Nathan Maves Subject: Re: sql joins in ibatis In-reply-to: <20060105164739.21069.qmail@web32508.mail.mud.yahoo.com> Sender: Nathan.Maves@Sun.COM To: user-java@ibatis.apache.org Message-id: MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/alternative; boundary="Boundary_(ID_Zx0rAYbeQilRhfqFAIiEaQ)" X-Gpgmail-State: !signed References: <20060105164739.21069.qmail@web32508.mail.mud.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Boundary_(ID_Zx0rAYbeQilRhfqFAIiEaQ) Content-type: text/plain; format=flowed; delsp=yes; charset=US-ASCII Content-transfer-encoding: 7BIT Where to start..... ClassNotFound is a java error. You have either misspelled you class name and or package. Check that you full class name including package is correct. The second problem that I see is in your result map. You specify dept.name when there is no property named that in your Dept.class. You have deptName so your result map should be dept.deptName. Nathan On Jan 5, 2006, at 9:47 AM, radha rukmani wrote: > Hi > > Can you please give more elaborate explanation. > > I changed person.java to look like > > public class Person > { > private int id; > private String firstName; > private String lastName; > private Date birthDate; > private double weightInKilograms; > private double heightInMeters; > private int deptNumber; > private Dept dept; > > public int getId() > { > return id; > } > > public void setId(int id) > { > this.id = id; > } > public String getFirstName() > { > return firstName; > } > > public void setFirstName(String firstName) > { > this.firstName = firstName; > } > public String getLastName() > { > return lastName; > } > > public void setLastName(String lastName) > { > this.lastName = lastName; > } > > public Date getBirthDate() > { > return birthDate; > } > > public void setBirthDate(Date birthDate) > { > this.birthDate = birthDate; > } > public double getWeightInKilograms() > { > return weightInKilograms; > } > > public void setWeightInKilograms(double weightInKilograms) > { > this.weightInKilograms = weightInKilograms; > ;} > public double getHeightInMeters() > { > return heightInMeters; > } > > public void setHeightInMeters(double heightInMeters) > { > this.heightInMeters = heightInMeters; > } > public int getDeptNumber() > { > return deptNumber; > } > > public void setDeptNumber(int deptNumber) > { > this.deptNumber = deptNumber; > } > > public void setDeptName(String deptName) > { > this.dept.setDeptName(deptName); > } > public String getDeptName() > { > return dept.getDeptName(); > } > public void setDeptId(int deptId) > { > this.dept.setDeptId(deptId); > } > > public int getDeptId() > { > return dept.getDeptId(); > } > } > > and Dept.java is, > public class Dept > { > private int deptId; > private String deptName; > > public int getDeptId() > { > return deptId; > } > > public void setDeptId(int deptId) > { > this.deptId = deptId; > } > public String getDeptName() > { > return deptName; > } > > public void setDeptName(String deptName) > { > this.deptName = deptName; > } > } > and the Person.xml is like > > > > > > > > > > > It throws me this error, > > Caused by: com.ibatis.common.exception.NestedRuntimeException: > Error configuring Result. Could not set ResultClass. Cause: > java.lang.ClassNotFoundException: com.comp.app.batchProcess.Person > Caused by: java.lang.ClassNotFoundException: > com.comp.app.batchProcess.Person > at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) > at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse > (SqlMapParser.java:45) > at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser > $11.process(SqlMapConfigParser.java:347) > at com.ibatis.common.xml.NodeletParser.processNodelet > (NodeletParser.java:112) > ... 8 more > Caused by: com.ibatis.common.exception.NestedRuntimeException: > Error parsing XPath '/sqlMap/resultMap'. > Cause:com.ibatis.common.exception.NestedRuntimeException: Error > configuring Result. Could not set ResultClass. Cause: > java.lang.ClassNotFoundException: com.comp.app.batchProcess.Person > Caused by: java.lang.ClassNotFoundException: > com.comp.app.batchProcess.Person > Caused by: com.ibatis.common.exception.NestedRuntimeException: > Error configuring Result. Could not set ResultClass. Cause: > java.lang.ClassNotFoundException: com.comp.app.batchProcess.Person > > Could you please let me know what should be done > > Thanks > > Zarar Siddiqi wrote: > Consider using composition: > > public class Person { > private Dept dept; > ... > } > > Then you can use a resultMap and assign values to bean properties > by doing: > > > > So you'll have: > > > > > > ...... > > > Zarar > > ----- Original Message ----- > From: radha rukmani > To: user-java@ibatis.apache.org > Sent: Wednesday, January 04, 2006 5:44 PM > Subject: sql joins in ibatis > > Hi > I am new to iBATIS. I was able to run the person example in the > ibatis website. > For one table, the example says, > > but if i want details from two tables, say person and dept table. I > have two bean classes person.java and dept.java > and if i want to select like, > select per_id as id, per_first_name as firstname, dept_name as > deptname from person,dept where dept_no = 2 > now resultClass="com.comp.app.batchProcess.Person" and > "com.comp.app.batchProcess.Dept" > how to get around this. Any help is greatly appreciated. > Thanks > > Yahoo! DSL Something to write home about. Just $16.99/mo. or less > > > Yahoo! Photos > Ring in the New Year with Photo Calendars. Add photos, events, > holidays, whatever. --Boundary_(ID_Zx0rAYbeQilRhfqFAIiEaQ) Content-type: text/html; charset=ISO-8859-1 Content-transfer-encoding: QUOTED-PRINTABLE Where to start.....

ClassNotFound is a java e= rror.=A0 You have either=A0misspelled you class name and or package.= =A0 Check that you full class name including package is correct.

The second pro= blem that I see is in your result map.=A0 You specify dept.name when = there is no property named that in your Dept.class.=A0 You have deptN= ame so your result map should be dept.deptName.

Nathan

On Jan 5, 2006, at 9:47 AM, radha rukmani wrote:

Hi
=A0
Can= you please give more elaborate explanation.
=A0
= I changed person.java to look like
=A0
public cla= ss Person
{
=A0=A0private int id;
=A0=A0private String first= Name;
=A0=A0private String lastName;
=A0=A0private Date birthDa= te;
=A0=A0private double weightInKilograms;
=A0=A0private doubl= e heightInMeters;
=A0=A0private int deptNumber;
=A0=A0private D= ept dept;
=A0=A0
=A0=A0public int getId()
=A0=A0{
=A0= =A0=A0return id;
=A0=A0}
=A0=A0
=A0=A0public void setId(int = id)
=A0=A0{
=A0=A0=A0this.id =3D id;=A0
=A0=A0}
=A0=A0public String getFir= stName()
=A0=A0{
=A0=A0=A0return firstName;
=A0=A0}
=A0= =A0
=A0=A0public void setFirstName(String firstName)
=A0=A0{=A0=A0=A0this.firstName =3D firstName;=A0
=A0=A0}
=A0=A0public String getLastNa= me()
=A0=A0{
=A0=A0=A0return lastName;
=A0=A0}
=A0=A0
= =A0=A0public void setLastName(String lastName)
=A0=A0{
=A0=A0= =A0this.lastName =3D lastName;= =A0
=A0=A0}
=A0=A0
=A0=A0public Date getBirthDate()=A0=A0{
=A0=A0=A0return birthDate;
=A0=A0}
=A0=A0
=A0= =A0public void setBirthDate(Date birthDate)
=A0=A0{
=A0=A0=A0th= is.birthDate =3D birthDate;= =A0
=A0=A0}
=A0=A0public double getWeightInKilogr= ams()
=A0=A0{
=A0=A0=A0return weightInKilograms;
=A0=A0}
= =A0=A0
=A0=A0public void setWeightInKilograms(double weightInKilog= rams)
=A0=A0{
=A0=A0=A0this.weightInKilograms =3D weightInKilog= rams;=A0
=A0=A0 ;}
=A0=A0public double getHeightInMeters()
=A0=A0{
=A0= =A0=A0return heightInMeters;
=A0=A0}
=A0=A0
=A0=A0public voi= d setHeightInMeters(double heightInMeters)
=A0=A0{
=A0=A0=A0thi= s.heightInMeters =3D heightInMeters;=A0
=A0=A0}
=A0=A0public int getDeptNumber()
= =A0=A0{
=A0=A0=A0return deptNumber;
=A0=A0}
=A0=A0
=A0= =A0public void setDeptNumber(int deptNumber)
=A0=A0{
=A0=A0= =A0this.deptNumber =3D deptNumber;=A0
=A0=A0}=A0=A0
=A0=A0
=A0=A0public void setDept= Name(String deptName)
=A0=A0{
=A0=A0=A0this.dept.setDeptName(de= ptName);
=A0=A0}
=A0=A0public String getDeptName()
= =A0=A0{
=A0=A0=A0return dept.getDeptName();
=A0=A0}
= =A0=A0public void setDeptId(int deptId)
=A0=A0{
=A0=A0=A0this.d= ept.setDeptId(deptId);
=A0=A0}
=A0=A0
=A0=A0public int getDe= ptId()
=A0=A0{
=A0=A0=A0return dept.getDeptId();
=A0=A0}
= }

and Dept.java is,
public class Dept
{
=A0= =A0private int deptId;
=A0=A0private String deptName;
=A0=A0=A0=A0public int getDeptId()
=A0=A0{
=A0=A0=A0return deptId;=A0=A0}
=A0=A0
=A0=A0public void setDeptId(int deptId)
= =A0=A0{
=A0=A0=A0this.deptId =3D deptId;=A0
=A0=A0}
=A0=A0public String getDe= ptName()
=A0=A0{
=A0=A0=A0return deptName;
=A0=A0}
=A0= =A0
=A0=A0public void setDeptName(String deptName)
=A0=A0{
= =A0=A0=A0this.deptName =3D deptName;=A0
=A0=A0}
}
and the Person.xml is l= ike
=A0
<typeAlias alias=3D= "dept" type=3D"com.pfizer.geca.batchProcess.Dept"/>
=A0
<resultMap id= =3D"= personMap" class=3D"com.pfizer.geca.batchProcess.Pers= on"= >
<result property"firstName" column=3D"PER_FIRST_NAME"/>
<= /SPAN>
<result property=3D"dept.na= me" column=3D"DEPT_NAME"/>
= </resultMap<= SPAN class=3D"Apple-style-span" style=3D"color: rgb(0, 128, 128); fon= t-size: 10px; ">>
=A0
= <select <= /SPAN>id=3D"getPersonByDept1" resultMap=3D"personMap">
SELECT<= /DIV>
PER_FIRST_NAME,
DEPT_NAME
FROM PE= RSON, DEPT
WHERE DEPT.DEPT_NO = =3D PERSON.DEPT_NO
AND DEPT.DEPT= _NO=3D#value#
</select>
=A0
It throws me this error,
=A0
Caused by: com.ibatis.common.except= ion.NestedRuntimeException: = Error configuring Result. Could not set ResultClass. Cause: java.lang.ClassNotFoundExcept= ion: com.comp.app.batchPro= cess.Person
Caused by: java.lang.ClassNotFoundException: com.comp.app.batchProcess.Pe= rson
at com.ibatis.common.xml.NodeletPars= er.parse(NodeletPars= er.java:53)at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.pars= e(SqlMapParser.java:= 45)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$11.= process(SqlMapConfig= Parser.java:347<= /FONT>)
at com.ibatis.common.xml.NodeletParser.processNodele= t(NodeletParser.java= :112)
... 8 mo= re
Caused by: com.ibatis.common.exception.NestedRunti= meException: Error parsing X= Path '/sqlMap/resultMap'. Cause:com.ibatis.common.exception.NestedRuntimeException: Error configuring Result. Co= uld not set ResultClass. Cause: java.lang.ClassNotFoundException: com.comp.app.batchProcess.Person
Caused by: java.lang.ClassNotFoundException: com.comp.app.batchProcess.Person
Caused by: c= om.ibatis.common.exception.NestedRuntimeException: Error configuring Result. Could not set Resul= tClass. Cause: j= ava.lang.ClassNotFoundException: com.comp.app.batchProcess.Person
=A0
Could you please le= t me know what should be done
=A0
Thanks
<= /FONT>
=A0
Zarar Sidd= iqi <zarar.siddiqi@ut= oronto.ca>=A0wrote:
Consider using composition= :
= =A0
public clas= s Person {
=A0=A0=A0 private Dept dept;
=A0=A0=A0 ...
}
=A0
Then you can use a resultMap = and assign values to bean properties by doing:
=A0
<result property=3D"dept.name" c= olumn=3D"PER_DEPT_NAME"/>
=A0
= So you'll have:
=A0
<= SPAN class=3D"Apple-style-span" style=3D"font-family: Arial; font-siz= e: 10px; "><select id=3D"getPerson" resultMap=3D"personMap">
=A0=A0=A0 ....
</select>
=A0
<resultMap id=3D"personMap" class=3D"com.comp.a= pp.batchProcess.Person">
=A0=A0=A0 <result property=3D"dept.name= " column=3D"PER_DEPT_NAME"/>
=A0=A0=A0 ......
</resultMap><= /SPAN>
=A0
Zarar
=A0
----- Original Message -----
To: user-java@ibatis.apache.org=
Sent: Wednesday, January 04, 20= 06 5:44 PM
sql joins in ibatis

Hi=A0
I am new to iBATIS. I was able to = run the person example in the ibatis website.=A0
For one table, the example says,
<s= elect id=3D"getPerson" resultClass=3D"com.comp.app.batchProcess.Perso= n">
=A0=A0=A0=A0=A0=A0=A0=A0=A0 SELECT=A0
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 PER_ID as id,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PER_F= IRST_NAME as firstName,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 PER_LAST_NAME as lastName,
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 PER_BIRTH_DATE as birthDate,
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 PER_WEIGHT_KG as weightInKilograms,
=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PER_HEIGHT_M as heightInMeters
= =A0=A0=A0=A0=A0=A0=A0=A0=A0 FROM PERSON
=A0=A0=A0=A0=A0=A0=A0=A0= =A0 WHERE PER_ID=3D#value#
=A0=A0=A0=A0 </select>
but if = i want details from two tables, say person and dept table. I have two= bean classes person.java and dept.java
and if i want to select li= ke,
select per_id as id, per_first_name as firstname, dept_name as= deptname from person,dept where dept_no =3D 2
now=A0 resultClass= =3D"com.comp.app.batchProcess.Person" and=A0 "com.comp.app.batchProce= ss.Dept"
how to get around this. Any help is greatly appreciated.<= BR>Thanks
=A0

Yahoo! DSL<= /SPAN>=A0Something t= o write home about. Just $16.99/mo. or less



Yahoo! Photos
Ring in the New Year with=A0Photo Calendars. Add photos, events, holidays, wha= tever.

--Boundary_(ID_Zx0rAYbeQilRhfqFAIiEaQ)--