Package org.hibernate

Examples of org.hibernate.SessionFactory


                }
                catch ( Exception e ) {
                    throw new CacheException( e );
                }
            }
            SessionFactory sessionFactory = locateSessionFactory();
            if ( sessionFactory == null ) {
                LOG.debug(
                        "SessionFactory is probably still being initialized..."
                                + " waiting for it to complete before enabling hibernate statistics monitoring via JMX"
                );
View Full Code Here


                if ( map == null ) {
                    return null;
                }
                Iterator values = map.values().iterator();
                while ( values.hasNext() ) {
                    SessionFactory sessionFactory = (SessionFactory) values.next();
                    Class sessionFactoryType = sessionFactory.getClass();
                    Field propertiesField = getField( sessionFactoryType, "properties" );
                    if ( propertiesField != null ) {
                        propertiesField.setAccessible( true );
                        Properties props = (Properties) propertiesField.get( sessionFactory );
                        if ( props != null && props.equals( properties ) ) {
View Full Code Here

      {
         sessionFactory_ = SecurityHelper.doPrivilegedAction(new PrivilegedAction<SessionFactory>()
         {
            public SessionFactory run()
            {
               SessionFactory factory = conf_.buildSessionFactory();
               return factory;
            }
         });
      }
View Full Code Here

         throw new JpaStoreException(
               "Entity class has one identifier, but it must not have @GeneratedValue annotation");
      }

      // Hack: MySQL needs to have fetchSize set to Integer.MIN_VALUE in order to do streaming
      SessionFactory sessionFactory = emf.createEntityManager().unwrap(Session.class).getSessionFactory();
      if (sessionFactory instanceof SessionFactoryImplementor) {
         Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect();
         if (dialect instanceof MySQLDialect) {
            setFetchSizeMinInteger = true;
         }
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

    /** 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;
    }
View Full Code Here

   * @see StatisticsServiceMBean#setSessionFactoryJNDIName(java.lang.String)
   */
  public void setSessionFactoryJNDIName(String sfJNDIName) {
    this.sfJNDIName = sfJNDIName;
    try {
      final SessionFactory sessionFactory;
      final Object jndiValue = new InitialContext().lookup( sfJNDIName );
      if ( jndiValue instanceof Reference ) {
        final String uuid = (String) ( (Reference) jndiValue ).get( 0 ).getContent();
        sessionFactory = SessionFactoryRegistry.INSTANCE.getSessionFactory( uuid );
      }
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) {
    SessionFactory factory = session.getSessionFactory();
    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.SessionFactory

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.