-
1. Re: Batch insert within session bean
bill.burke May 23, 2005 9:45 AM (in response to grzegorz.knapczyk)as the error message implies...It is illegal to insert the UserTransaction service into a session or MDB that has Container Managed Transactions.
-
2. Re: Batch insert within session bean
grzegorz.knapczyk May 23, 2005 10:07 AM (in response to grzegorz.knapczyk)Thanks for your answer. I am new to EJB, could you please tell me how may I force to flush data to the underlaying database within the session bean method?
I've tried with em.flush(), but it seems not to work:@Stateless public class TypesDAOBean implements TypesDAO { @Inject private EntityManager em; void batchInsertMethod() { TypeEntity e1; while (e1 = readFromTXTFile()) { em.persist( e1 ); em.flush(); } } }
or@Stateless public class TypesDAOBean implements TypesDAO { @Inject private EntityManager em; void batchInsertMethod() { org.jboss.ejb3.entity.HibernateSession hs = (HibernateSession)em; org.hibernate.Session session = hs.getHibernateSession(); TypeEntity e1; while (e1 = readFromTXTFile()) { em.persist( e1 ); session.flush(); session.clear(); } } }
In both cases the data are flushed after leaving the method batchInsertMethod(). -
3. Re: Batch insert within session bean
bill.burke May 23, 2005 10:42 AM (in response to grzegorz.knapczyk)You do know that batchInsertMethod() is running in a JTA transaction right? So, if you have code running in parallel, then you won't see these changes in the database...
Or...
Are you doing code from within batchInsertMethod that is trying to interact with persisted entities? -
4. Re: Batch insert within session bean
grzegorz.knapczyk May 24, 2005 3:28 AM (in response to grzegorz.knapczyk)Is it possible than to controll the transaction within batchInsertMethod()?
When I try to import large TXT file (with a lot of rows) within a single transaction, I crash the JBOSS server (out of heap)...