Package org.hibernate

Examples of org.hibernate.SessionFactory.openSession()


    );
    factory = configuration.buildSessionFactory();
    long subsequent = System.currentTimeMillis() - start;

    // Let's make sure the mappings were read in correctly (in termas of they are operational).
    Session session = factory.openSession();
    session.beginTransaction();
    session.createQuery( "from Test1" ).list();
    session.getTransaction().commit();
    session.close();
    factory.close();
View Full Code Here


      SessionFactory sessionFactory = buildSessionFactory();
      try {
         UserTransaction ut = (UserTransaction) ctx.lookup("UserTransaction");
         ut.begin();
         try {
            Session session = sessionFactory.openSession();
            session.getTransaction().begin();
            item = new Item("anItem", "An item owned by someone");
            session.persist(item);
            session.getTransaction().commit();
            session.close();
View Full Code Here

         }

         ut = (UserTransaction) ctx.lookup("UserTransaction");
         ut.begin();
         try {
            Session session = sessionFactory.openSession();
            session.getTransaction().begin();
            Item found = (Item) session.load(Item.class, item.getId());
            Statistics stats = session.getSessionFactory().getStatistics();
            log.info(stats.toString());
            assertEquals(item.getDescription(), found.getDescription());
View Full Code Here

         }

         ut = (UserTransaction) ctx.lookup("UserTransaction");
         ut.begin();
         try {
            Session session = sessionFactory.openSession();
            session.getTransaction().begin();
            assertNull(session.get(Item.class, item.getId()));
            session.getTransaction().commit();
            session.close();
         } catch(Exception e) {
View Full Code Here

    conControl.setVoidCallable(1);
    con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    conControl.setVoidCallable(1);
    con.isReadOnly();
    conControl.setReturnValue(false, 1);
    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.getTransaction();
    sessionControl.setReturnValue(tx, 1);
    tx.setTimeout(10);
    txControl.setVoidCallable(1);
View Full Code Here

    MockControl sessionControl = MockControl.createControl(Session.class);
    Session session = (Session) sessionControl.getMock();
    MockControl txControl = MockControl.createControl(Transaction.class);
    Transaction tx = (Transaction) txControl.getMock();

    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.beginTransaction();
    sessionControl.setReturnValue(tx, 1);
    session.isOpen();
    sessionControl.setReturnValue(true, 1);
View Full Code Here

    MockControl sessionControl = MockControl.createControl(Session.class);
    Session session = (Session) sessionControl.getMock();
    MockControl txControl = MockControl.createControl(Transaction.class);
    Transaction tx = (Transaction) txControl.getMock();

    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.beginTransaction();
    sessionControl.setReturnValue(tx, 1);
    session.isOpen();
    sessionControl.setReturnValue(true, 1);
View Full Code Here

    conControl.setVoidCallable(1);
    con.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
    conControl.setVoidCallable(1);
    con.isReadOnly();
    conControl.setReturnValue(false, 1);
    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.getTransaction();
    sessionControl.setReturnValue(tx, 1);
    tx.setTimeout(10);
    txControl.setVoidCallable(1);
View Full Code Here

    MockControl sessionControl = MockControl.createControl(Session.class);
    final Session session = (Session) sessionControl.getMock();
    MockControl txControl = MockControl.createControl(Transaction.class);
    Transaction tx = (Transaction) txControl.getMock();

    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.beginTransaction();
    sessionControl.setReturnValue(tx, 1);
    session.isOpen();
    sessionControl.setReturnValue(true, 1);
View Full Code Here

    MockControl sessionControl = MockControl.createControl(Session.class);
    Session session = (Session) sessionControl.getMock();
    MockControl txControl = MockControl.createControl(Transaction.class);
    Transaction tx = (Transaction) txControl.getMock();

    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.beginTransaction();
    sessionControl.setReturnValue(tx, 1);
    session.isOpen();
    sessionControl.setReturnValue(true, 1);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.