aspose file tools*
The moose likes Object Relational Mapping and the fly likes PropertyAccessException: IllegalArgumentException occurred calling getter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "PropertyAccessException: IllegalArgumentException occurred calling getter " Watch "PropertyAccessException: IllegalArgumentException occurred calling getter " New topic
Author

PropertyAccessException: IllegalArgumentException occurred calling getter

vidya archana
Ranch Hand

Joined: Oct 29, 2002
Posts: 36
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
Klitters Mike
Greenhorn

Joined: Aug 30, 2005
Posts: 2
Vidhya

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

Mike
vidya archana
Ranch Hand

Joined: Oct 29, 2002
Posts: 36
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
Vibha Jindal
Greenhorn

Joined: Nov 25, 2003
Posts: 10
CAn you paste the complete exception trace?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PropertyAccessException: IllegalArgumentException occurred calling getter