private void mergeInTransaction ( EntityManager em , Collection objects ) { EntityTransaction tx = null ; try { tx = em . getTransaction ( ) ; tx . begin ( ) ; for ( Object o : objects ) { em . merge ( o ) ; } tx . commit ( ) ; } catch ( RuntimeException e ) { if ( tx != null && tx . isActive ( ) ) { tx . rollback ( ) ; } throw e ; } }
Persist collection of objects .