Package org.hibernate

Examples of org.hibernate.SessionFactory$SessionFactoryOptions


    }
    throw new HibernateException( "Cannot unwrap the following type: " + cls );
  }

  private OgmSession buildOgmSession(Session session) {
    final SessionFactory sessionFactory = ( (HibernateEntityManagerFactory) hibernateEm.getEntityManagerFactory() )
        .getSessionFactory();
    final OgmSessionFactory ogmSessionFactory = new OgmSessionFactoryImpl( (SessionFactoryImplementor) sessionFactory );
    return new OgmSessionImpl( ogmSessionFactory, (EventSource) session );
  }
View Full Code Here


    Object o = EM.getDelegate();
    System.out.println(o.getClass());
   
    Session s = (Session) o;
   
    SessionFactory sf = s.getSessionFactory();
   
  }
View Full Code Here

   * Associates the given session with the current thread of execution.
   *
   * @param session The session to bind.
   */
  public static void bind(org.hibernate.Session session) {
    SessionFactory factory = session.getSessionFactory();
    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }
View Full Code Here

  private String filename;
  private List queryStrings;

  public void doStart() {
    Session session = null;
    SessionFactory sessionFactory = null;
    Transaction transaction = null;
    try {    
      sessionFactory = getConfiguration().buildSessionFactory();
      session = sessionFactory.openSession();
      transaction = session.beginTransaction();
      // TODO: this is not the most efficient loop (opening/closing file)
      for (Iterator iter = queryStrings.iterator(); iter.hasNext();) {
        String query = (String) iter.next();
       
        List list = session.createQuery(query).list();
       
        if(getFileName()!=null) {
          PrintWriter pw = null;
          try {
            File file = new File( getOutputDirectory(), getFileName() );
            getTemplateHelper().ensureExistence( file );
            pw = new PrintWriter( new FileWriter( file, true ) );     
            getArtifactCollector().addFile( file, "query-output" );
           
            for (Iterator iter1 = list.iterator(); iter1.hasNext();) {
              Object element = iter1.next();
              pw.println(element);
            }
           
          }
          catch (IOException e) {
            throw new ExporterException("Could not write query output",e);
          } finally {
            if(pw!=null) {
              pw.flush();
              pw.close();
            }
          }
        }
      }
      transaction.commit();
    } catch(HibernateException he) {
      if(transaction!=null) {
        transaction.rollback();
      }
      throw new ExporterException("Error occured while trying to execute query", he);
    } finally {     
      if(session!=null) {
        session.close();       
      }
      if(sessionFactory!=null) {
        sessionFactory.close();
      }
     
     
    }
  }
View Full Code Here

   * Associates the given session with the current thread of execution.
   *
   * @param session The session to bind.
   */
  public static void bind(org.hibernate.Session session) {
    SessionFactory factory = session.getSessionFactory();
    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }
View Full Code Here

    LOG.trace( "Resolving serialized SessionFactory" );
    return locateSessionFactoryOnDeserialization( uuid, name );
  }

  private static SessionFactory locateSessionFactoryOnDeserialization(String uuid, String name) throws InvalidObjectException{
    final SessionFactory uuidResult = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid );
    if ( uuidResult != null ) {
      LOG.debugf( "Resolved SessionFactory by UUID [%s]", uuid );
      return uuidResult;
    }

    // in case we were deserialized in a different JVM, look for an instance with the same name
    // (provided we were given a name)
    if ( name != null ) {
      final SessionFactory namedResult = SessionFactoryRegistry.INSTANCE.getNamedSessionFactory( name );
      if ( namedResult != null ) {
        LOG.debugf( "Resolved SessionFactory by name [%s]", name );
        return namedResult;
      }
    }
View Full Code Here

   * Associates the given session with the current thread of execution.
   *
   * @param session The session to bind.
   */
  public static void bind(org.hibernate.Session session) {
    final SessionFactory factory = session.getSessionFactory();
    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }
View Full Code Here

    return uuid == null ? null : getSessionFactory( uuid );
  }

  public SessionFactory getSessionFactory(String uuid) {
    LOG.debugf( "Lookup: uid=%s", uuid );
    final SessionFactory sessionFactory = sessionFactoryMap.get( uuid );
    if ( sessionFactory == null && LOG.isDebugEnabled() ) {
      LOG.debugf( "Not found: %s", uuid );
      LOG.debugf( sessionFactoryMap.toString() );
    }
    return sessionFactory;
View Full Code Here

    // configure.getEventListeners().setPreUpdateEventListeners(
    // new PreUpdateEventListener[] { new PreUpdateListener() });
    // configure.getEventListeners().setLoadEventListeners(
    // new LoadEventListener[] { new LoadListener(),
    // new DefaultLoadEventListener() });
    final SessionFactory sessionFactory = configure.buildSessionFactory();
    // Session session = sessionFactory.openSession();
    // Transaction transaction = session.beginTransaction();
    // session.createQuery("from Stanowisko").list();
    // Stanowisko s = (Stanowisko) session.load(Stanowisko.class, 1);
    // s.setNazwa(System.currentTimeMillis() + " miro");
    // System.out.println(s.getNazwa());
    // session
    // .createQuery(
    // "update Pracownik s SET s.imie='haha2222' where s.idPracownik<2")
    // .executeUpdate();
    // int executeUpdate = session.createQuery(
    // "Update Pracownik Set imie ='sdfc' where imie like '%afsd'")
    // .executeUpdate();
    // System.out.println("ilosc = " + executeUpdate);
    // transaction.commit();

    // Session session2 = sessionFactory.openSession();
    // Transaction transaction2 = session2.beginTransaction();
    // // Stanowisko s2 = (Stanowisko) session2.load(Stanowisko.class, 1);
    // Pracownik p = (Pracownik) session2.load(Pracownik.class, 2);
    // System.out.println(p.getStanowisko().getNazwa());

    JFrame jf = new JFrame();
    jf.setSize(100, 100);
    jf.setVisible(true);
    JButton jbButton = new JButton();
    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

   * Associates the given session with the current thread of execution.
   *
   * @param session The session to bind.
   */
  public static void bind(org.hibernate.Session session) {
    SessionFactory factory = session.getSessionFactory();
    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.SessionFactory$SessionFactoryOptions

Copyright © 2018 www.massapicom. 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.