We spoke here about Statement Timeout to set on a Datasource http://www.javamonamour.org/2013/04/statement-timeout-on-datasource.html
If you use an EntityManager, you don't have access to the javax.sql.Statement object. This is the beauty of abstraction (sarcasm here): it prevents you from using the full power of the underlying technology, and it forces you to awkward acrobatics.
I would give a try to javax.persistence.query.timeout
http://stackoverflow.com/questions/24244621/set-timeout-on-entitymanager-query
https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/
see https://docs.oracle.com/javaee/6/api/javax/persistence/Query.html
but it works (actually, they told me it doesn't work AT ALL with WebLogic 12 and Eclipse JPA) only if you use Queries with EntityManager....
If you use an EntityManager, you don't have access to the javax.sql.Statement object. This is the beauty of abstraction (sarcasm here): it prevents you from using the full power of the underlying technology, and it forces you to awkward acrobatics.
I would give a try to javax.persistence.query.timeout
http://stackoverflow.com/questions/24244621/set-timeout-on-entitymanager-query
https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/
query.setHint("javax.persistence.query.timeout", 2000);
see https://docs.oracle.com/javaee/6/api/javax/persistence/Query.html
but it works (actually, they told me it doesn't work AT ALL with WebLogic 12 and Eclipse JPA) only if you use Queries with EntityManager....