[Hibernate-JIRA] Created: (HHH-6032) Executable actions, created inside lifecycle callbacks, are ignored during flush
by Roman Boroday (JIRA)
Executable actions, created inside lifecycle callbacks, are ignored during flush
--------------------------------------------------------------------------------
Key: HHH-6032
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6032
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 4.0.0.Alpha1, 3.6.2, 3.6.1
Reporter: Roman Boroday
When try to persist another entity inside event callback (for example create an audit record during PostPersist event), an executable action is being created, and it is added into the actions queue list, but ignored, because the for statement inside the ActionQueue class doesn't use the actual collection size, but an initial value instead:
private void executeActions(List list) throws HibernateException {
int size = list.size();
for ( int i = 0; i < size; i++ ) {
execute( (Executable) list.get( i ) );
}
list.clear();
session.getTransactionCoordinator().getJdbcCoordinator().executeBatch();
}
In my example PostPersist callback will be called inside the execute( (Executable) list.get( i ) ) call, and a new Executable will be created during merge() or persist() call, and added into the list collection, but when the for condition will be checked after execute (...) is done, it's going to use the initially calculated value, instead of the current list.size().
It seems like it is an expected behavior, but, first, if the size value changed in debug mode, it executes those added actions just fine, and, second, if it's a bad practice to create new entities inside lifecycle events callbacks, then maybe it would make sense to rise an exception, or show a warning when list size is changed to let developers know that they are doing something wrong?
With the current implementation no errors or warnings are shown, but no new entities created either, leaving developers just guessing of what could go wrong.
--
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
15 years
[Hibernate-JIRA] Created: (HHH-6031) Can't reassociate immutable proxy to sesssion using LockMode.NONE
by Nicolas Estrada (JIRA)
Can't reassociate immutable proxy to sesssion using LockMode.NONE
-----------------------------------------------------------------
Key: HHH-6031
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6031
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.2
Environment: Hibernate 3.6.2.Final, MySQL
Reporter: Nicolas Estrada
Priority: Critical
Hello,
Occasionally but not always I get a weird exception when I attempt to associate a detached proxy of an immutable (ie. read only) entity to the persistence context using LockMode.NONE. I should note that it doesn't always occur but sufficiently that I can somewhat reproduce it every hundreth or so lock() invocations.
Here is the stack trace:
2011-03-18 02:18:30.703 [TransactionSubscriber] SEVERE com.eads.impact.appli.impl.mip.oigmgr - Fatal database error
com.eads.impact.base.impl.coredb.hibernate.ProxyDatabaseException: Unable to lock the object: ObjectType_$$_javassist_29 @40264c[id=29000000000000000001] with lock mode: NONE
at com.eads.impact.base.impl.coredb.DefaultPersistenceService.lock(DefaultPersistenceService.java:444)
at com.eads.impact.base.impl.coredb.HibernateDatabaseService.lock(HibernateDatabaseService.java:671)
at com.eads.impact.appli.impl.mip.oigmgr.gis.ObjectItemGisElement.processObjectItemType(ObjectItemGisElement.java:597)
at com.eads.impact.appli.impl.mip.oigmgr.gis.ObjectItemGisElement.processObjectItemType(ObjectItemGisElement.java:556)
at com.eads.impact.appli.impl.mip.oigmgr.ContextLayer.processDynamicPendingContextUpdates(ContextLayer.java:1280)
at com.eads.impact.appli.impl.mip.oigmgr.OigLayerDatabaseListener.flush(OigLayerDatabaseListener.java:382)
at com.eads.impact.base.impl.coredb.DatabaseListenerManager.notifyDatabaseListeners(DatabaseListenerManager.java:237)
at com.eads.impact.base.impl.coredb.cluster.TransactionSubscriber.run(TransactionSubscriber.java:89)
Caused by: org.hibernate.TransientObjectException: Instance was not associated with this persistence context
at org.hibernate.engine.StatefulPersistenceContext.isReadOnly(StatefulPersistenceContext.java:1344)
at org.hibernate.engine.StatefulPersistenceContext.setReadOnly(StatefulPersistenceContext.java:1355)
at org.hibernate.proxy.AbstractLazyInitializer.setReadOnly(AbstractLazyInitializer.java:288)
at org.hibernate.proxy.AbstractLazyInitializer.setSession(AbstractLazyInitializer.java:134)
at org.hibernate.engine.StatefulPersistenceContext.reassociateProxy(StatefulPersistenceContext.java:573)
at org.hibernate.engine.StatefulPersistenceContext.unproxyAndReassociate(StatefulPersistenceContext.java:618)
at org.hibernate.event.def.DefaultLockEventListener.onLock(DefaultLockEventListener.java:67)
at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:774)
at org.hibernate.impl.SessionImpl.fireLock(SessionImpl.java:766)
at org.hibernate.impl.SessionImpl.access$600(SessionImpl.java:156)
at org.hibernate.impl.SessionImpl$LockRequestImpl.lock(SessionImpl.java:2369)
at com.eads.impact.base.impl.coredb.DefaultPersistenceService.lock(DefaultPersistenceService.java:428)
... 7 more
The bug is quite odd because it is telling me that I need to associate the entity with my session but that is what I'm trying to do! Thanks for any feedback.
--
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
15 years
[Hibernate-JIRA] Created: (HHH-6029) Calling empyt() on lazy PersistentSet throws NullPointerException
by Robin Palotai (JIRA)
Calling empyt() on lazy PersistentSet throws NullPointerException
-----------------------------------------------------------------
Key: HHH-6029
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6029
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.2
Reporter: Robin Palotai
Priority: Minor
Calling empyt() on lazy PersistentSet throws NullPointerException. This is trivial, since the method directly calls set.isEmpty, where set is null yet.
Normally one would not use the PersistentSet interface, just java.util.Set, therefore calling empty() would not be possible.
But tools or apis may rely on using reflection to determine methods to call. In this case, ScalaTest's ShouldMatcher has the syntax
someSet should be ('empty)
where based on the 'empty symbol, it looks for a method returning boolean either called empty() or isEmpty(). One would expect that java.util.Set has isEmpty, but this is preceded by PersistentSet's empty.
The workaround is trivial, use the 'Empty symbol instead.
As a solution, is it possible to add nullness check to empty() and invoke isEmpty() behavior on null?
--
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
15 years
[Hibernate-JIRA] Created: (HHH-2710) Cannot specify on-delete="cascade" for a map or a set with just one element
by Gerald Klopp (JIRA)
Cannot specify on-delete="cascade" for a map or a set with just one element
---------------------------------------------------------------------------
Key: HHH-2710
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2710
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.4
Reporter: Gerald Klopp
Priority: Minor
I'd like to specify the on-delete="cascade" attribute for a map or for a set with just one element.
When I try to do this, I get the following exception :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade"
The on-delete="cascade" attribute can be specified for more complex relationships like one-to-many. But it seems that the case of a simple map or set is not covered.
- Mapping document example:
<hibernate-mapping>
<class name="Document" table="DOCUMENT">
<id name="id" column="DOCUMENT_ID">
<generator class="native" />
</id>
<map name="titles" table="DOCUMENT_TITLE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<index column="LANGUAGE" type="string" />
<element column="TITLE" type="text" not-null="true" />
</map>
<set name="references" table="DOCUMENT_REFERENCE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<element type="string" column="REFERENCE" />
</set>
</class>
</hibernate-mapping>
- Exception stack trace :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": Document.references
Exception in thread "main" java.lang.ExceptionInInitializerError
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at fr.gklopp.test.hibernate3.simple.DocumentManager.createAndStoreDocument(DocumentManager.java:23)
at fr.gklopp.test.hibernate3.simple.DocumentManager.main(DocumentManager.java:68)
Caused by: org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": fr.gklopp.test.hibernate3.simple.Document.references
at org.hibernate.mapping.Collection.validate(Collection.java:267)
at org.hibernate.mapping.Set.validate(Set.java:19)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
- Database : Oracle 10
--
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
15 years