This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

CGLIB Exception

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chi Hang Chiu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An ArrayList is a List. And Hibernate support Sets, Bags, Lists and Maps.

Why are you still mapping it as a Set?
 
Hug your destiny! And hug this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!