java - What are the implications of running a query against a MySQL database via Hibernate without starting a transaction? -


it seems me have code not starting transaction yet read-only operations our queries via jpa/hibernate straight sql seem work. hibernate/jpa session have been opened our framework few spots in legacy code found no transactions being opened.

what seems end happening code runs long not use entitymanager.persist , entitymanager.merge. once in awhile (maybe 1/10) times servlet container fails error...

failed load resource: server responded status of 500 (org.hibernate.exception.jdbcconnectionexception: last packet received server 314,024,057 milliseconds ago.  last packet sent server 314,024,057 milliseconds ago. longer server configured value of 'wait_timeout'. should consider either expiring and/or testing connection validity before use in application, increasing server configured values client timeouts, or using connector/j connection property 'autoreconnect=true' avoid problem.)  

as far can tell few spots in our application code not have transactions started before query made have problem. else think non-transactional query running causes behaviour?

fyi here our stack...

-guice -guice-persist -guice-servlet -mysql 5.1.63 -hibernate/c3p0 4.1.4.final -jetty

yes, think.

if start query without opening transaction, transaction opened automatically underlying layer. connection, opened transaction, returned connection pool , given user, receive connection already-opened transaction, , lead inconsistent state.

here in company had lot of problems in past read-only non-transactional queries, , adjusted our framework handle this. besides that, talked bonecp developers , accepted develop set of features handle problem, auto-rollback uncommitted transactions returned pool, , print stack trace of method forgot commit transaction.

this matter discussed here: http://jolbox.com/forum/viewtopic.php?f=3&t=98


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -