Alex Pooley's Blog

Hello there, my name is Alex Pooley and I'm a freelance web developer residing in Perth, Western Australia. My passion is in the development of web sites that solve everyday problems. Here's a gallery of some of my notable work. If you need a web site designer or developer, contact me with further details. Lastly, you can read more about me.

Speed Up Your JPA Transactions

June 19th, 2007

Why don't you subscribe to my blog while you're here? I'm a freelance web developer and I blog about Ruby, Rails, and business online.

Go ahead and subscribe to my RSS feed. Thanks for visiting!

JPA is a new standardized Java persistence system that takes the best parts of the current persistence technologies. Recently while using JPA, I had noticed that large transactions took increasingly longer to process. It turned out that by default, JPA cross checks a pending query with all managed entities to ensure that the query is up to date. To disable this default behaviour and shoulder the object management yourself, you can do the following:


EntityManagerFactory emf = Persistence.createEntityManagerFactory("YOUR_PU");
EntityManager em = emf.createEntityManager();
em.setFlushMode(FlushModeType.COMMIT); // disable auto-management