I'm trying to set a query + lock timeout in my entityManagerFactory since I read at https://msdn.microsoft.com/en-us/library/ms378988(v=sql.110).aspx that by default the lock timeout is indefinitely.
Now I've been trying a couple of things, but as the documentation suggests the success of these properties varies depending on the DB. I have a couple of 100 queries, so I'd prefer to do this on the entityManager level.
What I've tried:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws JDBCDSLogException {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("com.my.app.model");
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
return em;
}
Properties additionalProperties() {
//more settings
properties.setProperty("javax.persistence.query.timeout", "1");
properties.setProperty("javax.persistence.lock.timeout", "1");
return properties;
}
But my queries aren't timing out after 1ms. (just a sample value so I can test quickly, it'll end up in a configuration file).
I guess SQLJDBC4 should have an equivalent of hibernate.connection.oracle.jdbc.readtimeout
but I can't seem to find it.