Package org.hibernate

Examples of org.hibernate.SessionFactory.openSession()


    /** Begin the transaction */
    public void begin() throws Exception {
        log.debug("Begin transaction. Id=" + getId());
        HibernateSessionFactoryProvider hibernateSessionFactoryProvider = CoreServices.lookup().getHibernateSessionFactoryProvider();
        SessionFactory sessionFactory = hibernateSessionFactoryProvider.getSessionFactory();
        session = sessionFactory.openSession();
        session.getTransaction().begin();
        active = true;
    }

    /** Complete the transaction */
 
View Full Code Here


  @Override
  public void index(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fulltextSession = Search.getFullTextSession( session );
    try {
      fulltextSession.createIndexer( clazz )
          .batchSizeToLoadObjects( batchSize )
          .cacheMode( CacheMode.NORMAL )
View Full Code Here

  @Override
  public void optimize(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    fullTextSession.beginTransaction();
    fullTextSession.getSearchFactory().optimize( clazz );
    fullTextSession.getTransaction().commit();
    session.close();
View Full Code Here

  @Override
  public void purge(String entity) {
    Class<?> clazz = getEntityClass( entity );

    SessionFactory factory = getSessionFactory();
    Session session = factory.openSession();
    FullTextSession fullTextSession = Search.getFullTextSession( session );
    fullTextSession.beginTransaction();
    fullTextSession.purgeAll( clazz );
    fullTextSession.getTransaction().commit();
    session.close();
View Full Code Here

        final SessionFactory sessionFactory = cfg.buildSessionFactory();

        Provider<Session> sessionProvider = new Provider<Session>() {
            public Session get() {
                return sessionFactory.openSession();
            }
        };
        Provider<SessionFactory> sessionFactoryProvider = new Provider() {
            public Object get() {
                return sessionFactory;
View Full Code Here

  public void testUserSuppliedSession() throws Exception {
    DbPersistenceServiceFactory persistenceServiceFactory = new DbPersistenceServiceFactory();
    SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
    DbPersistenceService persistenceService = (DbPersistenceService) persistenceServiceFactory.openService();
   
    Session session = sessionFactory.openSession();
    persistenceService.setSession(session);
   
    persistenceService.getSession();
    assertNull(persistenceService.transaction);
    persistenceService.close();
View Full Code Here

    DbPersistenceServiceFactory persistenceServiceFactory = new DbPersistenceServiceFactory();
    SessionFactory sessionFactory = persistenceServiceFactory.getSessionFactory();
    DbPersistenceService persistenceService = (DbPersistenceService) persistenceServiceFactory.openService();
   
    Session session = sessionFactory.openSession(connection);
    persistenceService.setSession(session);
    persistenceService.setRollbackOnly();
   
    persistenceService.getSession();
    assertNull(persistenceService.transaction);
View Full Code Here

            HttpServletResponse response) throws Exception {

       
      
        SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
        Session session = sessionFactory.openSession();

        session.beginTransaction();

        //Sauvegarde des regions
        initRegions(session);
View Full Code Here

      utControl.setReturnValue(status, 1);
    }

    final List list = new ArrayList();
    list.add("test");
    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.getSessionFactory();
    sessionControl.setReturnValue(sf, 1);
    session.isOpen();
    sessionControl.setReturnValue(true, 1);
View Full Code Here

    MockControl sfControl = MockControl.createControl(SessionFactory.class);
    final SessionFactory sf = (SessionFactory) sfControl.getMock();
    final MockControl sessionControl = MockControl.createControl(Session.class);
    final Session session = (Session) sessionControl.getMock();
    sf.openSession();
    sfControl.setReturnValue(session, 1);
    session.getSessionFactory();
    sessionControl.setReturnValue(sf, 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.