Thanks Nathan,
You are right, I changed the resulMap as, dept.deptName,
Thanks
Nathan Maves <[EMAIL PROTECTED]> wrote:
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:
HiCan you please give more elaborate explanation.I changed person.java to look likepublic 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 i s,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<typeAlias alias="dept" type="com.pfizer.geca.batchProcess.Dept"/><resultMap id="personMap" class="com.pfizer.geca.batchProcess.Person"><result property= "firstName" column="PER_FIRST_NAME"/><result property="dept.name" column="DEPT_NAME"/></resultMap><select id="getPersonByDept1" resultMap="personMap">SELECTPER_FIRST_NAME,DEPT_NAMEFROM PERSON, DEPTWHERE DEPT.DEPT_NO = PERSON.DEPT_NOAND DEPT.DEPT_NO=#value#</select>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.PersonCaused by: java.lang.ClassNotFoundException: com.comp.app.batchProcess.Personat 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 moreCaused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/resultMap'. Cause: FONT>com.ibatis.common.exception.NestedRuntimeException: Error configuring Result. Could not set ResultClass. Cause: java.lang.ClassNotFoundException: com.comp.app.batchProcess.PersonCaused by: java.lang.ClassNotFoundException: com.comp.app.batchProcess.PersonCaused by: com.ibatis.common.exception.NestedRuntimeException: Error configuring Result. Could not set ResultClass. Cause: java.lang.ClassNotFoundException: com.comp.app.batchProcess.PersonCould you please let me know what should be doneThanksZarar Siddiqi <[EMAIL PROTECTED]> wrote:Consider using composition: public class Person {private Dept dept;...}Then you can use a resultMap and assign values to bean properties by doing:<result property="dept.name" column="PER_DEPT_NAME"/>So you'll have:<select id="getPerson" resultMap="personMap">....</select>< FONT face=Arial size=2><resultMap id="personMap" class="com.comp.app.batchProcess.Person"><result property="dept.name" column="PER_DEPT_NAME"/>......</resultMap>Zarar----- Original Message -----Sent: Wednesday, January 04, 2006 5:44 PMSubject: sql joins in ibatisHi
I am new to iBATIS. I was able to run the person example in the ibatis website.
For one table, the example says,
<select id="getPerson" resultClass="com.comp.app.batchProcess.Person">
SELECT
PER_ID as id,
PER_FIRST_NAME as firstName,
PER_LAST_NAME as lastName,
PER_BIRTH_DATE as birthDate,
PER_WEIGHT_KG as weightInKilograms,
PER_HEIGHT_M as heightInMeters
FROM PERSON
WHERE PER_ID=#value#
</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 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! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
Reply via email to