-->
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.  [ 3 posts ] 
Author Message
 Post subject: PropertyAccessException
PostPosted: Tue Dec 12, 2006 10:15 am 
Beginner
Beginner

Joined: Tue Sep 05, 2006 2:36 pm
Posts: 24
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents:

User:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="UserAdapter" table="users">
<id name="id" column="userId">
<generator class="native" />
</id>
<property name="name"/>
<set name="items" table="users_by_items">
<key column="userId"/>
<many-to-many column="userId" class="Item">
</set>
</class>

</hibernate-mapping>

Item:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="ItemAdapter" table="items">
<id name="id" column="itemId">
<generator class="native" />
</id>
<property name="name"/>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.test.UserAdapter.setItems

...

Caused by: net.sf.cglib.beans.BulkBeanException: org.hibernate.collection.PersistentSet
at com.test.UserAdapte$$BulkBeanByCGLIB$$f5c06d7d.setPropertyValues(<generated>)
at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:212)
... 60 more
Caused by: java.lang.ClassCastException: org.hibernate.collection.PersistentSet

Name and version of the database you are using:

MySQL 5

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html



More info:

User class:
Code:
public class User {
    Long id;
    String name;
    List<Item> items;
}

public class UserAdapter extends User implements IDataAccess{
  ... more code ....
}


Item class:
Code:
public class Item {
    Long id;
    String name;
}

public class ItemAdapter extends Item implements IDataAccess{
  ... more code ....
}


I'm using a class called UserAdapter, that inherits from User and a ItemAdapter that inherits from Item. Both implements an interface to allow objects to be saved. So, Hibernate should return instances of ItemAdapter instead of Item, but I don't think that can cause a ClassCastException.

Any ideas?

PS: I had already set the hibernate.cglib.use_reflection_optimizer property to false in hibernate.cfg.xml.


Top
 Profile  
 
 Post subject: Post your java class source
PostPosted: Tue Dec 12, 2006 10:51 am 
Newbie

Joined: Mon Dec 11, 2006 10:43 am
Posts: 3
I think you should post more details of your class files. It seems like there is some type of setter problem.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 3:16 pm 
Beginner
Beginner

Joined: Tue Sep 05, 2006 2:36 pm
Posts: 24
I found out the origin of my problem, but is still there.
My class is using a setter of type List, and I'm using the tag set to define a collection.

The problem is that in the XML editor, Eclipse shows me this error:

Code:
The content of element type "list" must match
"(meta*,subselect?,cache?,synchronize*,comment?,key,(index|list-index),(element|one-to-many|
many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-
delete-all?,filter*)".


The list portion of the mapping file is:
Code:
      <list name="dictionaries" table="users_by_items" >
         <list-index></list-index>
         <index column="itemIdx" />
         <key column="usertId"/>
         <many-to-many column="userId" class="UserAdapter">
        </list>


The error log says:

Code:
10594 [main] ERROR org.hibernate.util.XMLHelper  - Error parsing XML: XML InputStream(17) The content of element type "list" must match "(meta*,subselect?,cache?,synchronize*,comment?,key,(index|list-index),(element|one-to-many|many-to-many|composite-element|many-to-any),loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,filter*)".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.