I am writing an appln connecting two tables. This is the exception I am getting. -- "et.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter "
Anyone pls help me to find out why this exception coming?
/* * Created on Aug 29, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package object;
import org.apache.struts.action.*;
/** * @author 128801 * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Parent extends ActionForm {
public int id; public String name; public Child child;
public Parent() { id = 0; name = ""; }
public void setId(int i) { this.id = i; } public int getId() { return this.id; }
public void setName(String name) { if(name == null) name = ""; this.name = name; } public String getName() { return this.name; }
public void setChild(Child child) { this.child = child; } public Child getChild() { return child; } public static void main(String arg[]){
} }
Child.java
/* * Created on Aug 29, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package object;
import org.apache.struts.action.*;
/** * @author 128801 * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Child extends ActionForm { private int id; private int parentId; private String name;
public Child() { id = 0; parentId = 0; name = ""; }
public void setId(int i) { this.id = i; } public int getId() { return this.id; }
public void setParentId(int i) { this.parentId = i; } public int getParentId() { return this.parentId; }
public void setName(String name) { if(name == null) name = ""; this.name = name; } public String getName() { return this.name; } }
In createUser fuunciton()
/** adds employe info to table **/ public boolean createUser(Parent emp){ System.out.println("Creating user"); boolean status = false; try{ this.session =sessions.openSession(); tx = session.beginTransaction(); session.save(emp); System.out.println("identifier == "+session.getIdentifier(emp));
Child ch = new Child(); ch.setId(1); ch.setParentId(10); ch.setName("childname"); session.save(ch); System.out.println("identifier1 == "+session.getIdentifier(ch)); session.flush(); tx.commit(); session.close(); status = true; } catch (HibernateException e){ status = false; System.out.println("eeeeeeee="+ e); if (tx != null) try { tx.rollback(); } catch (HibernateException e1) { System.out.println("rollback not successful"); } if (session != null) try { session.close(); sessions.close(); } catch (HibernateException e2) { System.out.println("session close not successful"); } } return status; }
The values are getting stored for Parent. But when I included the code for storing the child values its throwing exception.