Brassrat wrote:
can someone please help me - I have a JBoss (3.2.3) service with a managed datasource. WIthin this service i need to run one or more threads. The threads need to run with their own sessions and transaction contexts. Can i use the same session factory for all the threads but obtain a different transaction context? I don't want the threads to enlist in the same transaction - so i don't think i can use (new InitialContext()).lookup("UserTransaction") to obtain a UserTransaction in each thread, but if i use the (managed) session factory to get a session if i then try to 'beginTransaction' i get the following error:
beginTransaction on session failed, no UserTransaction manager, embedded exception: net.sf.hibernate.TransactionException: Could not register Synchronization [Could not register Synchronization]
So how do i create a new session and begin a new transaction in each thread? Do i have to configure an unmanaged session factory? and manage my own session pool?
Why not to put your business logic into SLSB and call it from your service? It will provide you both transaction management and hibernate session management, isn't it exactly what you need?