2 Replies Latest reply: Oct 17, 2011 10:27 AM by Ivan Latysh RSS

Mutiple sessions and transactions.

Ivan Latysh Newbie

Hello All!


Can anybody point me into the right direction. I need to have 2 independant sessions while I am processing the data.


So far I had no luck, I have tried to brake a routine into 2 calls and annotate each call with "@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)" But it does not work.


EJB3 on JBossAS 5.1.0.

  • 1. Re: Mutiple sessions and transactions.
    Wolf-Dieter Fink Master

    Hi Ivan,

    could you describe a bit more in detail what you want to achieve?


    As I understand you will commit/rollback both different !??

  • 2. Re: Mutiple sessions and transactions.
    Ivan Latysh Newbie

    I am using Hibernate fulltext search, and I need to read underlaying indexes and save data back into the database.

    So I need 1 session to get to the indexes:


    // get session
    Session indexReaderSession = (Session) manager.getDelegate();
    // get fulltext session
    FullTextSession fullTextSession = Search.getFullTextSession(indexReaderSession);
    // get search factory
    SearchFactory searchFactory = fullTextSession.getSearchFactory();
    // get directory provider
    DirectoryProvider dealDirectoryProvider = searchFactory.getDirectoryProviders(MyClass.class)[0];
    // get reader provider
    ReaderProvider readerProvider = searchFactory.getReaderProvider();
    // get index reader
    IndexReader reader = readerProvider.openReader(dealDirectoryProvider);


    And 1 session to write the data.


    I can not use the same session in this case.