Methods Summary |
---|
private void | applyCacheSettings(org.hibernate.cfg.Configuration configuration)
if ( settings.getCacheConcurrencyStrategy() != null ) {
Iterator iter = configuration.getClassMappings();
while ( iter.hasNext() ) {
PersistentClass clazz = (PersistentClass) iter.next();
Iterator props = clazz.getPropertyClosureIterator();
boolean hasLob = false;
while ( props.hasNext() ) {
Property prop = (Property) props.next();
if ( prop.getValue().isSimpleValue() ) {
String type = ( ( SimpleValue ) prop.getValue() ).getTypeName();
if ( "blob".equals(type) || "clob".equals(type) ) {
hasLob = true;
}
if ( Blob.class.getName().equals(type) || Clob.class.getName().equals(type) ) {
hasLob = true;
}
}
}
if ( !hasLob && !clazz.isInherited() && settings.overrideCacheStrategy() ) {
configuration.setCacheConcurrencyStrategy( clazz.getEntityName(), settings.getCacheConcurrencyStrategy() );
}
}
iter = configuration.getCollectionMappings();
while ( iter.hasNext() ) {
Collection coll = (Collection) iter.next();
configuration.setCollectionCacheConcurrencyStrategy( coll.getRole(), settings.getCacheConcurrencyStrategy() );
}
}
|
private void | applyMappings(org.hibernate.cfg.Configuration configuration)
String[] mappings = settings.getMappings();
for ( int i = 0; i < mappings.length; i++ ) {
configuration.addResource( settings.getBaseForMappings() + mappings[i], ExecutionEnvironment.class.getClassLoader() );
}
|
public void | complete()
if ( sessionFactory != null ) {
sessionFactory.close();
sessionFactory = null;
}
configuration = null;
|
public org.hibernate.cfg.Configuration | getConfiguration()
return configuration;
|
public org.hibernate.dialect.Dialect | getDialect()
return DIALECT;
|
public org.hibernate.SessionFactory | getSessionFactory()
return sessionFactory;
|
public void | initialize()
if ( sessionFactory != null ) {
throw new IllegalStateException( "attempt to initialize already initialized ExecutionEnvironment" );
}
if ( ! settings.appliesTo( getDialect() ) ) {
return;
}
Configuration configuration = new Configuration();
configuration.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
settings.configure( configuration );
applyMappings( configuration );
applyCacheSettings( configuration );
if ( settings.createSchema() ) {
configuration.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
}
// make sure we use the same dialect...
configuration.setProperty( Environment.DIALECT, getDialect().getClass().getName() );
configuration.buildMappings();
settings.afterConfigurationBuilt( configuration.createMappings(), getDialect() );
SessionFactory sessionFactory = configuration.buildSessionFactory();
this.configuration = configuration;
this.sessionFactory = sessionFactory;
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
public boolean | isAllowRebuild()
return allowRebuild;
|
public void | rebuild()
if ( !allowRebuild ) {
return;
}
if ( sessionFactory != null ) {
sessionFactory.close();
sessionFactory = null;
}
sessionFactory = configuration.buildSessionFactory();
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
public void | setAllowRebuild(boolean allowRebuild)
this.allowRebuild = allowRebuild;
|