[Hibernate-JIRA] Created: (HHH-2914) Hibernate cannot save properties that arae collections of elements of union-subclasses.
by Frederico Guimarães (JIRA)
Hibernate cannot save properties that arae collections of elements of union-subclasses.
---------------------------------------------------------------------------------------
Key: HHH-2914
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2914
Project: Hibernate3
Issue Type: Bug
Components: core, query-sql
Affects Versions: 3.2.5
Reporter: Frederico Guimarães
Priority: Critical
I have a class Departament that have a collection of class AbstractPerson:
<bag lazy="true" name="person" cascade="save-update">
<key column="idPerson" />
<one-to-many class="AbstractPerson" />
</bag>
AbstractPerson is abstract an have a lot os subclasses all of then mapped using union-subclass (none of the abstract classes has a table, all of them are mapped with abstract="true")
When I do a code like:
AbstractPerson student = new Student();
Departament departament = new Departament();
departament.getPersons().add( student );
...
session.saveOrUpdate( student )
...
I receive the exception:
org.hibernate.exception.SQLGrammarException: could not insert collection: [br.com.project.model.Departament.persons#29164]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1183)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:145)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at br.com.utilities.db.hibernate.AppDBHibernate.execute(AppDBHibernate.java:785)
at br.com.utilities.db.hibernate.AppDBHibernate.execute(AppDBHibernate.java:754)
at br.com.mindsatwork.mopi.importer.Importer.importInspections(Importer.java:733)
at br.com.mindsatwork.mopi.importer.AppMain.main(AppMain.java:120)
Caused by: java.sql.BatchUpdateException: Base table or view not found message from server: "Table 'project.AbstractPerson' doesn't exist"
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1492)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1146)
... 13 more
...
if show_sql is active hibernate prints the sql:
update AbstractPerson set idDepartament =? where id=?
Why is Hibernate trying to access a table that wat NOT declared and does not exist (as the AbstractPerson is mapped with abstract "true") instead of look for the type of the object (in this case Student) and create a sql with the right table (update user set idDepartament =? where id=?)?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months
[Hibernate-JIRA] Created: (HHH-2910) entity version increased after merging Map
by kyrieeleison (JIRA)
entity version increased after merging Map
------------------------------------------
Key: HHH-2910
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2910
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.5
Environment: core 3.2.5, entity manager 3.3.1
Reporter: kyrieeleison
EntityB extends abstract EntityA by primary key join
EntityC has a composite key, which are "mapColumn" and "joinColumn"
EntityB, EntityC has a one-to-many, manty-to-one bid relationship,
For EntityA:
<inheritance strategy="JOINED"/>
<id name="joinColumn"/>
For EntityB:
<!-- primary key join EntityA -->
<primary-key-join-column name="joinColumn" referenced-column-name="joinColumn" />
<!-- one to many Map -->
<one-to-many fetch="EAGER" name="entityCes" target-entity="EntityC" mapped-by="entityB">
<map-key name="mapColumn"/>
<join-column name="joinColumn"/>
<cascade>
<cascade-all/>
</cascade>
</one-to-many>
For EntityC:
<!-- composite id -->
<id name="joinColumn"/>
<id name="mapColumn"/>
<!-- many to one EntityB -->
<many-to-one name="entityB" target-entity="EntityB">
<join-column name="joinColumn" insertable="false" updatable="false"/>
</many-to-one>
Merge EntityB again and again without changing any properties, its version number get increased
If change the one-to-many to Set , not Map, its version number stay unchanged as expected
Is that a desired behavior?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 2 months