Forums Register Login

PropertyAccessException: IllegalArgumentException occurred calling getter

+Pie Number of slices to send: Send
Hi,

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?

Thanks

Vidya
+Pie Number of slices to send: Send
Vidhya

If you could elaborate more on ur issue,i could help u out.

Mike
+Pie Number of slices to send: Send
There are two tables parent and child

Table : Parent

Name Null? Type
----------------------------------------- -------- ---------------
ID NOT NULL NUMBER(38)
NAME VARCHAR2(100)

table:child

Name Null? Type
----------------------------------------- -------- --------------
ID NOT NULL NUMBER(38)
PARENT_ID NUMBER(38)
NAME VARCHAR2(100)

this is jst for the starting..
The code i've written is

hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/mytesting</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<!-- Mapping files -->
<mapping resource="Mapping.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Mapping.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="object.Parent" table="vid_parent">
<id name="id" type="int" unsaved-value="null">
<column name="id" sql-type="int" not-null="true"/>
<generator class="sequence">
<param name="sequence">vid_parent_seq</param>
</generator>
</id>
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
</class>
<class name="object.Child" table="vid_child">
<id name="id" type="int" unsaved-value="null">
<column name="id" sql-type="int" not-null="true"/>
<generator class="sequence">
<param name="sequence">vid_child_seq</param>
</generator>
</id>
<property name="name">
<column name="name" length="100" not-null="false"/>
</property>
<many-to-one name="parentId" class="object.Parent" column="parent_id"/>
</class>
</hibernate-mapping>


Parent.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 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.

Thanks

Vidya
+Pie Number of slices to send: Send
CAn you paste the complete exception trace?
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 5507 times.
Similar Threads
Mapping a oracle boolean to Java boolean data type in hibernate
Need clarification in Many to one Mapping- Please help.
Enum used for a primary key pair !
problem with hibernate
Callback threw IllegalArgumentException error
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:49:34.