[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3876?page=c...
]
Bob Glamm commented on HHH-3876:
--------------------------------
Ugh. I just tripped this with 3.5.6-Final and 3.6.6.Final, using Hibernate strictly as a
JPA 2 provider.
The easiest way to replicate it is with a structure something like this:
{code:java}
public enum UserRole {
ROLE_BASIC_USER,
ROLE_SITE_ADMIN,
...
}
@Entity
public class User {
...
@Enumerated(EnumType.STRING)
@ElementCollection(fetch=FetchType.LAZY)
@CollectionTable(...)
private Set<UserRole> userRoles;
...
}
@Embeddable
public class Vote {
...
@ManyToOne
private User votingUser;
...
}
@Entity
public class Game {
...
boolean purchased;
...
@ElementCollection(fetch=FetchType.LAZY, targetClass=Vote.class)
@CollectionTable(...)
@Valid
@NotNull
private Set<Vote> votes = new HashSet<Vote>();
...
}
{code}
Create several User objects each with various UserRoles. Create a Game object, add
several Vote objects to the Game object. Then, within a transaction that retrieves a Game
object and performs Game.setPurchased(true), you'll get "collection[] was not
processed by flush()" on User.userRoles. During the COMMIT phase of the transaction,
Hibernate's debug messages indicate that it is loading all of the Vote objects as well
as all of the UserRole objects - and, judging by other Hibernate issues (and my own
experimentation), it appears to be loading all those objects because of the @NotNull and
@Valid annotations sitting on Set<Vote> votes.
Changing the fetch type to FetchType.EAGER on BOTH collections (Set<Vote> votes and
Set<UserRole> userRoles) is a workaround for the problem, but that is an awful
solution, since both collections could be large. Eliminating @NotNull and @Valid from
Set<Vote> votes also fixes the problem, but that renders Hibernate Validation
useless for that column.
collection [] was not processed by flush() triggering for unknown
reasons
-------------------------------------------------------------------------
Key: HHH-3876
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3876
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0.Beta-1
Reporter: Mark Derricutt
We've started to notice the following exceptions being triggered from Hibernate
3.5.0-SNAPSHOT (built locally), but only under certain circumstances (editing a specific
user, whilst being logged into the application as a specific user). After stepping
through both our application and hibernate through the whole update/commit process being
run, I can't find anything that would be causing this problem.
During processing, I see calls to
org.hibernate.engine.Collections#prepareCollectionForUpdate for
CollectionEntry[smx3.schema.PartyRole.agreementsFrom#2006094] (and other elements in the
same collection) which is listed in the trace below.
The collection which triggers the exception isn't consistently the same one, but
seems to be localized to 4-5 different collections, I've also noticed that if I
single-stepping through the process, if sometimes completes fine, which may indicate some
race conditions somewhere.
As I'm not entirely sure why the exception is being thrown, I'm not sure if this
is a problem with Hibernate, or something wrong in our application somewhere. Is there
anyway I can identify why a collection entry wouldn't have been processed (and what
does "processed" actually mean?).
24.04.2009 15:57:33.180 *ERROR* [btpool0-1] 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: collection
[smx3.schema.PartyRole.agreementsFrom] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:228)
at
org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:356)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1031)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:369)
at
org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:88)
at com.atomikos.icatch.jta.Sync2Sync.beforeCompletion(Sync2Sync.java:73)
at
com.atomikos.icatch.imp.TransactionStateHandler.commit(TransactionStateHandler.java:253)
at
com.atomikos.icatch.imp.CompositeTransactionImp.doCommit(CompositeTransactionImp.java:509)
at
com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:138)
at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:297)
at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:608)
at
com.atomikos.icatch.jta.UserTransactionManager.commit(UserTransactionManager.java:148)
at smx3.envers.TransactionFilter.afterHandle(TransactionFilter.java:242)
at org.restlet.Filter.handle(Filter.java:197)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
at org.restlet.Application.handle(Application.java:341)
at org.restlet.ext.wadl.WadlApplication.handle(WadlApplication.java:705)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Router.handle(Router.java:504)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Router.handle(Router.java:504)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
at org.restlet.Component.handle(Component.java:673)
at org.restlet.Server.handle(Server.java:331)
at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:68)
at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:147)
at com.noelios.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:881)
at
nz.co.smx.rest.RestActivator$RestActivatorClassLoaderServlet.service(RestActivator.java:182)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at
org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:51)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
at
org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:87)
at
org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:63)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
24.04.2009 15:57:33.183 *WARN* [btpool0-1] atomikos Unexpected error in beforeCompletion:
org.hibernate.AssertionFailure: collection [smx3.schema.PartyRole.agreementsFrom] was not
processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:228)
at
org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:356)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1031)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:369)
at
org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:88)
at com.atomikos.icatch.jta.Sync2Sync.beforeCompletion(Sync2Sync.java:73)
at
com.atomikos.icatch.imp.TransactionStateHandler.commit(TransactionStateHandler.java:253)
at
com.atomikos.icatch.imp.CompositeTransactionImp.doCommit(CompositeTransactionImp.java:509)
at
com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:138)
at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:297)
at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:608)
at
com.atomikos.icatch.jta.UserTransactionManager.commit(UserTransactionManager.java:148)
at smx3.envers.TransactionFilter.afterHandle(TransactionFilter.java:242)
at org.restlet.Filter.handle(Filter.java:197)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
at org.restlet.Application.handle(Application.java:341)
at org.restlet.ext.wadl.WadlApplication.handle(WadlApplication.java:705)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Router.handle(Router.java:504)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at org.restlet.Router.handle(Router.java:504)
at org.restlet.Filter.doHandle(Filter.java:150)
at org.restlet.Filter.handle(Filter.java:195)
at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
at org.restlet.Component.handle(Component.java:673)
at org.restlet.Server.handle(Server.java:331)
at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:68)
at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:147)
at com.noelios.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:881)
at
nz.co.smx.rest.RestActivator$RestActivatorClassLoaderServlet.service(RestActivator.java:182)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at
org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:51)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722)
at
org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:87)
at
org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:63)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira