0 Replies Latest reply on Jan 11, 2006 11:26 AM by Peter Goetz

    [Hibernate] Error subclassing EntityBeans and relations

    Peter Goetz Newbie

      Hi out there,

      it is really difficult to create a useful and short subject for my problem, so I just named the important things and explain here.
      I have an EJB3 application on JBoss 4.0.3 with Entity Beans (persisted by Hibernate). All of my Entity Beans have one parent Entity Bean that has various attributes that every table of our database has - among others the primary key "id". Now I have one Entity Bean (MenuXForm) that has a relation to "Menu" and "Form" Entities (ManyToOne). When selecting MenuXForm entities I get an exception when there is for example a Menu Entity with id = 12 selected, and there already exists a Form Entity with id = 12 in the cache. Then Hibernate tries to set the existing Form Entity as a Menu Entity. The exception that occurs is a

      org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of de.weltbild.wbmsadmin.j2ee.entities.MenuXForm.setMenu


      I think Hibernate sees that both Menu und Form are EntityObjects (superclass defining the primary key) and therefore gives back the first EntityObject with the searched primary key. It does not look if the type of the object is right.

      Is this an error in Hibernate or isn't it possible to have one superclass for all entities defining pk and other attributes? From the OO view I would say I'm right because my Form Object "is a" Entity Object.

      Could you please help me further? Thank you very much!

      Yours, Peter