J'ai un problème étrange, je teste hibernate avec JBoss sur les EJB 2.1.
Lorsque j'utilise les objets sans JBoss, Hibernate ne rencontre aucun problème lors de la sauvegarde mais lorsque Hibernate fonctionne avec JBoss et ce mapping particulièrement, une erreur survient.
J'ai testé avec d'autre mappings plus simples et cela fonctionne dans JBoss.
J'ai les classes suivantes :
class AbstractDataObject { }
class AbstractEntity extends AbstractDataObject { }
class PersonBean extends AbstractEntity { }
class PersonBMP extends PersonBean { }
Les classes à enregistrer sont :
- AbstractEntity,
- PersonBMP.
Hibernate version:
Hibernate 3.1.2
Mapping documents:
<class name="AbstractEntity" table="ENTITIES" abstract="true">
<id name="primaryKey" column="entity_id" type="long">
<generator class="identity"/>
</id>
<timestamp name="modificationDate" column="modification"/>
<property name="creationDate" column="creation" type="timestamp" lazy="true"/>
<property name="archived" column="archived" type="boolean"/>
<property name="name" column="name" type="string" length="50" not-null="true"/>
<property name="comment" column="comment" type="string" length="255"/>
<property name="identity" column="identity" type="string" length="15"/>
<property name="image" column="image" type="blob" lazy="true"/>
<joined-subclass name="PersonBMP" table="PERSONS">
<key column="person_id"/>
<property name="firstname" column="firstname" type="string" length="50"/>
<property name="birthDate" column="birthdate" type="timestamp" lazy="true"/>
<many-to-one name="title" class="TitleBMP" column="title_id"/>
</joined-subclass>
</class>
Full stack trace of any exception that occurs:
2006-04-03 21:09:23,633 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null id in PersonBMP entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
...
at java.lang.Thread.run(Unknown Source)
2006-04-03 21:09:23,648 ERROR [ManagerTools] ManagerTools@5476a7 (class PersonBMP), PersonBMP@57dc21 (null,false,2006-04-03 21:09:23.602, Titi, null, null, Title:1, null)
org.hibernate.AssertionFailure: null id in PersonBMP entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
...
at java.lang.Thread.run(Unknown Source)
2006-04-03 21:09:23,648 ERROR [AbstractDataObject] PersonBMP@57dc21 (null,false,2006-04-03 21:09:23.602, Titi, null, null, Title:1, null)
org.hibernate.HibernateException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of AbstractDataObject.primaryKey
at ManagerTools.persist(ManagerTools.java:511)
...
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of AbstractDataObject.primaryKey
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
...
at ManagerTools.persist(ManagerTools.java:480)
... 88 more
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
Name and version of the database you are using:
MySQL
|