Package org.hibernate

Examples of org.hibernate.SessionFactory.openSession()


    jbButton.setText("mirek");
    jbButton.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        Stanowisko s = (Stanowisko) sessionFactory.openSession().load(
            Stanowisko.class, 1);
        System.out.println(s.getNazwa());

      }
    });
View Full Code Here


        // check if we can look up the Hibernate session factory that should of been bound because of
        // the hibernate.session_factory_name was specified in the properties (in peristence.xml above).
        SessionFactory hibernateSessionFactory = rawLookup("modelSessionFactory",SessionFactory.class);
        assertNotNull("jndi lookup of hibernate.session_factory_name should return HibernateSessionFactory", hibernateSessionFactory);

        Session session = hibernateSessionFactory.openSession();
        Employee emp = (Employee)session.get(Employee.class,1);
        assertTrue("name read from hibernate session is Sally", "Sally".equals(emp.getName()));
    }

    // Test that an extended Persistence context can be injected into a Hibernate Session
View Full Code Here

  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

  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

  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

  @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

      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
     
      cleanSqlCache.put(processEngine, cleanSql);
    }

    Session session = sessionFactory.openSession();
    try {
      for (String query : cleanSql) {
        // log.trace(query);
        session.createSQLQuery(query).executeUpdate();
      }
View Full Code Here

     
      tableNamesCache.put(processEngine, tableNames);
    }

    String recordsLeftMsg = "";
    Session session = sessionFactory.openSession();
    try {
      for (String tableName : tableNames) {
        String countSql = "select count(*) as RECORD_COUNT_ from "+tableName;
        SQLQuery sqlQuery = session.createSQLQuery(countSql);
        sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
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.