public void insert ( Object object ) { EntityManager entityManager = null ; try { entityManager = entityManagers . poll ( ) ; entityManager . getTransaction ( ) . begin ( ) ; try { entityManager . persist ( object ) ; entityManager . getTransaction ( ) . commit ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; entityManager . getTransaction ( ) . rollback ( ) ; } } finally { if ( entityManager != null ) entityManagers . add ( entityManager ) ; } }
Insert an entity that must not already exist within the database . Within JPA this uses the persist method as opposed to the merge .