-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Bad handling of javax.persistence.query.timeout
PostPosted: Mon May 02, 2016 10:45 am 
Newbie

Joined: Mon May 02, 2016 9:34 am
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: Bad handling of javax.persistence.query.timeout
PostPosted: Fri Jun 10, 2016 2:09 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
This is not an issue, you are just making mistaking EMF properties with query hints.

According to the JPA docs, the properties that you provide when you call:

Code:
Persistence.createEntityManagerFactory(pu,properties);


mean that:

Quote:
These properties may be used to override the values of the corresponding elements in the persistence.xml file or specify values for properties not specified in the persistence.xml (and may be null if no properties are specified).


On the other hand, the query hints must be supplied explicitly when you create a Query instance.


Top
 Profile  
 
 Post subject: Re: Bad handling of javax.persistence.query.timeout
PostPosted: Fri Jul 01, 2016 8:13 am 
Newbie

Joined: Mon May 02, 2016 9:34 am
Posts: 2
No, I do not think that I am mistaking EMF properties with query hints.

The issue is: javax.persistence.query.timeout is a property supported by the standard.
It may legally appear either in persistence.xml and in a EMF properties map.
True?

Its intended effect is obviously to set a timeout value on each subsequent query.
Do we agree on that?

I do not think that it is an optional parameter that a persistence provider is free to ignore.
Do we agree on that, too?

So the question is: why does Hibernate not call
Quote:
PreparedStatement.setQueryTimeout(...)
when the parameter was present in one of those locations mentioned above?

Thanks, again.
H.


Top
 Profile  
 
 Post subject: Re: Bad handling of javax.persistence.query.timeout
PostPosted: Fri Jul 01, 2016 8:22 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
There is no section in the JPA specification to state your assumptions. But feel free to open a Jira issue, of course. If you supply a PR, it will have a higher priority to be integrated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.