|
What happens is that the persist process uses 2 connection:
-
one connection for the generated id
-
one to save the Entity
and the second connection is used also by the query
TypedQuery<String> query = em.createQuery( "SELECT d.name FROM Document d", String.class );
List<String> results = query.getResultList();
this connection has autocommit set to false and being the query not enclosed into a transaction no commit is executed on the connection keeping the table Document locked.
The first connection is the first released so the connection pool returns it to the drop schema process, but when the drop of the table Document is executed, the lock kept by the second connection causes the deadlock.
The PR https://github.com/hibernate/hibernate-orm/pull/1099 provides a possible solution. Steve Ebersole what do you think?
|