1

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.

Joe Leager
  • 11
  • 2

1 Answers1

0

1ms is too small value to test time out. try 1000 or more.

Nitin
  • 1,582
  • 11
  • 12
  • How is it too small to try out? It means I should be getting a timeout within 1ms. – Joe Leager Mar 07 '16 at 12:32
  • your database most certainly would not honour 1ms considering amount of work involved for it and the network or other latency – Nitin Mar 07 '16 at 15:19
  • check http://stackoverflow.com/questions/24244621/set-timeout-on-entitymanager-query – Nitin Mar 07 '16 at 15:22
  • You mean like the thing I said in my opening post which I said wasn't working, and which the documentation explicitly says doesn't work on every DB? – Joe Leager Mar 08 '16 at 06:29
  • for best hardware and database today I know of, 1ms is insanely low to respond within. please look for query time out and latency and 'read' material you may find. good luck – Nitin Mar 08 '16 at 08:58