Hello all.
Version: Hibernate 5.1.0.Final.
When
javax.persistence.query.timeout is set to "4000", for example, it is expected that Hibernate issues a
Code:
PreparedStatement.setQueryTimeout(4)
to the JDBC driver, some time after
Connection.prepareStatement(), converting milliseconds to seconds.
Well, this is true after the following two statements:
Code:
Query.setHint( "javax.persistence.query.timeout", "4000" )
TypedQuery.setHint( "javax.persistence.query.timeout", "4000" )
However: when
javax.persistence.query.timeout is set in either
Code:
persistence.xml
Persistence.createEntityManagerFactory(pu,properties);
EntityManagerFactory.createEntityManager(map);
EntityManager.setProperty(propertyName,value);
EntityManager.find(entityClass,primaryKey,properties);
and when the
setHint() method is not explicitly used by application code, then the property is
not passed to
setQueryTimeout at all.
I was unable to tell whether this behavior is also shared by
Code:
lock(entity,lockMode,properties)
refresh(entity,properties)
I was able to verify, however, that
javax.persistence.query.timeout specified in
persistence.xml, for example, finds its way into
EntityManager.getProperties().
But it does not get any further from there.
In fact, by tracing the code of
EntityManager.find in a debugger I got the impression that the properties object of an EntityManager is simply ignored when it is processed in a Hibernate Session.
But I may be mistaken.
Please look into the matter and fix.
Thanks.