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