File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes org hibernate PropertyAccessException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org hibernate PropertyAccessException" Watch "org hibernate PropertyAccessException" New topic

org hibernate PropertyAccessException

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580

I have 3 tables in my database:


and mapped them as a ManyToMany-Relation:

The relationship works well by doing some HQLs (JPA-QLs). But when I want to persist a new Person-Instance, the following stacktrace occurs:

This is my session-bean:

This is my view to obtain the list of selected roles (this works):

The persist works only, if the user will not select any roles. Then a person-instance with its name and id will be stored in the database. By persisting any roles, the stacktrace above occurs.

I have tried a lot but I cannot solve the problem.
Any Idea, how I can solve that problem??

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I do not understand, why Hibernate complains that the "object is not an instance of declaring class" when searching the primary key from Table ROLE. I know, Users is my actual instance..but Hibernat cannot save a User-Record without considering the m:n-Relation..I mean, it should save the join-table automatically open a new session for that..

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: org hibernate PropertyAccessException
It's not a secret anymore!