-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: one-to-many exception : PropertyAccessException
PostPosted: Sun Aug 01, 2004 10:48 am 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
Hi,
I got the error message:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INFO org.springframework.transaction.interceptor.TransactionInterceptor - Invoking rollback for transaction on method 'getOrgs' in class [net.canal.core.service.OrgManager] due to throwable [org.springframework.orm.hibernate.HibernateSystemException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of net.canal.core.persistence.Org.setPrograms; nested exception is net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of net.canal.core.persistence.Org.setPrograms]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have two entities: Org and Program. Each Org can have many Programs (one-to-many association)

Here is my mapping files and Java codes:
1. Parent mapping file and java code
----------------------------------------------------------------------------------
<class name="net.canal.core.persistence.Org" table="orgs">
<id name="id" type="long" column="OID" unsaved-value="0">
<generator class="identity"/>
</id>

<property name="name" type="string" not-null="true"
column="NAME"/>
<property name="description" type="string" column="DESCR"/>

<set name="programs" table="programs" inverse="true" lazy="true">
<key column="OID"/>
<one-to-many class="net.canal.core.persistence.Program"/>
</set>

</class>
----------------------------------------------------------------------------------
public class Org extends BaseObject implements Serializable {

private Long id;
private String name;
private String description;
protected List programs = new ArrayList();
......
public void setPrograms(List programs) {
this.programs = programs;
}

public List getPrograms() {
return this.programs;
}

}
--------------------------------------------------------------------------------
2. Child mapping file
--------------------------------------------------------------------------------
<class name="net.canal.core.persistence.Program" table="programs">
<id name="id" type="long" column="PID" unsaved-value="0">
<generator class="identity"/>
</id>

<property name="name" type="string" not-null="true"
column="NAME"/>
<property name="description" type="string" column="DESCR"/>

<many-to-one name="org" column="OID"
class="net.canal.core.persistence.Org" not-null="true"/>

</class>
--------------------------------------------------------------------------------


The exception happens when I call:
return getHibernateTemplate().find(findOrgsQuery);

(findOrgsQuery is a very simple string "from Org". I am using Spring's getHibernateTemplate() here)

I guess this is because there is no children (programs) when I try to find Orgs in the one-to-many mapping relationship, but I do not know how to fix this.

thanks in advance for your help !
lixin chu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 01, 2004 9:52 pm 
Regular
Regular

Joined: Tue Jul 13, 2004 2:27 am
Posts: 73
Location: Singapore
I know what's wrong:
- the mapping files use <set ...> but the .Java files use List.

Once I change to Set in the java files, everything works fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.