File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes CGLIB Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "CGLIB Exception" Watch "CGLIB Exception" New topic
Author

CGLIB Exception

Chi Hang Chiu
Greenhorn

Joined: Sep 25, 2004
Posts: 5
Hi all, I am using Hibernate 3.0.5 on tomcat5 and trapped by an error of "org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.tailorsys.crm.bean.AccountForm.setAddressesList" Please Help!!!

I have two classes AccountForm & Address. Each AccountForm can have corresponding Address up to 4.

The simple AccountForm & Address class are as following:
public final class AccountForm extends ValidatorForm implements Serializable {
private ArrayList addresses = new ArrayList();
//address
public List getAddressesList() {
return addresses;
}


public void setAddressesList(List list) {
addresses = (ArrayList) list;
}


public Address getAddresses(int index) {
while (index >= addresses.size()) {
addresses.add(new Address());
}
return (Address) addresses.get(index);
}


public void setAddresses(int index, Address in) {
if (index >= addresses.size()) {
int i = addresses.size();
do {
addresses.add(new Address());
} while (index >= ++i);
}
addresses.set(index, in);
}
}

Address:
public final class Address implements Serializable {
private long address_id;
public long getAddress_id() {
return address_id;
}
public void setAddress_id(long address_id) {
this.address_id = address_id;
}
}

I am using AccountForm.hbm.xml as following:
<class name="com.tailorsys.crm.bean.AccountForm" table="account">
<id name="ac_id" type="long" unsaved-value="0" >
<column name="account_id" sql-type="bingint(20)" not-null="true"/>
<generator class="increment"/>
</id>
<set name="addressesList" table="accountaddress">
<key column="account_id"/>
<many-to-many column="address_id" class="com.tailorsys.crm.bean.Address"/>
</set>
</class>
<class name="com.tailorsys.crm.bean.Address" table="address">
<id name="address_id" type="long" unsaved-value="0" >
<column name="address_id" sql-type="bingint(20)" not-null="true"/>
<generator class="increment"/>
</id>
</class>
</hibernate-mapping>

Jonathan/eom
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

When you set hibernate.cglib.use_reflection_optimizer=false what did your logs say? You might get more help from that. One thing you could check: your mapping looks suspicious - your addressesList property is a List, but you have mapped it as a Set.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Chi Hang Chiu
Greenhorn

Joined: Sep 25, 2004
Posts: 5
The setting of user_reflection_optimizer=false produces a series of SQL-like statement in the tomcat console. I didn't see them useful.

The addressesList originally is an ArrayList and I searched over the net and someone said ArrayList is not supported in Hibernate and so I changed it to List.

Originally posted by Paul Sturrock:
When you set hibernate.cglib.use_reflection_optimizer=false what did your logs say? You might get more help from that. One thing you could check: your mapping looks suspicious - your addressesList property is a List, but you have mapped it as a Set.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

An ArrayList is a List. And Hibernate support Sets, Bags, Lists and Maps.

Why are you still mapping it as a Set?
 
 
subject: CGLIB Exception