1 Reply Latest reply on Mar 22, 2011 3:58 AM by allen li

    Strange issue using hibernate

    allen li Newbie

      Hi all,

                I use below code to test our Teiid .  Our vdb have 2 datasouce , And thay are XA. Our xa transaction time out is 300 second.


           1. I declare an session through sessionfactory.openSession().

           2. I use this session do a "select" command.

           3. Than I close session.

           4. sleep 200 second.

           5. I declare an session through sessionfactory.openSession() again. I use same sessionfactory.

           6. sleep 150 second. At this time, running this of program has spent 350. It is over "xa transaction time out" (300 second)

           7, When do a "select" command . it will throw an exception.

      Caused by: Transaction is not active: tx=TransactionImple < ac, BasicAction: 10105ce2:9195:4d821f41:5fe4 status: ActionStatus.ABORTED >


           Does sessionfactory.openSession() have cache?

           Or I am wrong with my code.

           If I am wrong,please correct me.


           If I use jdbc to create connection, I can not find any question.




              ///////////////////  code ///////////////////////////////////

              Configuration cfg = initConfig();



              SessionFactory sessionfactory = cfg.buildSessionFactory();


              Transaction tx = null;



                  for (int i = 0; i < 2; i++) {

                      Session session = sessionfactory.openSession();

                      tx = session.beginTransaction();


                      String entityName = "test.MobType";

                      List results = session.createCriteria(entityName)



                      if (i > 0) {

                          Thread.sleep(100 * 1000);



                      results = session.createCriteria(entityName).setMaxResults(1)





                      System.out.println("begin sleep no commit;");

                      Thread.sleep(250 * 1000);

                      System.out.println("end sleep");



              }catch(Exception e){