Methods Summary |
---|
public final void | addAdditionalProperty(java.lang.String name, java.lang.String value)
if ( !getExcludedPropertyNames().contains( name ) ) {
if ( additionalProperties == null ) {
additionalProperties = new HashMap();
}
additionalProperties.put( name, value );
}
|
protected void | addAll(java.util.Properties target, java.util.Map source)
Iterator itr = source.entrySet().iterator();
while ( itr.hasNext() ) {
final Map.Entry entry = ( Map.Entry ) itr.next();
final String propertyName = ( String ) entry.getKey();
final String propertyValue = ( String ) entry.getValue();
if ( propertyName != null && propertyValue != null ) {
// Make sure we don't override previous set values
if ( !target.keySet().contains( propertyName ) ) {
if ( !getExcludedPropertyNames().contains( propertyName) ) {
target.put( propertyName, propertyValue );
}
}
}
}
|
public void | addMapResource(java.lang.String mapResource)
if ( mapResources==null || mapResources.length()==0 ) {
mapResources = mapResource.trim();
}
else {
mapResources += ", " + mapResource.trim();
}
|
protected final org.hibernate.cfg.Configuration | buildConfiguration()
Configuration cfg = new Configuration().setProperties( buildProperties() );
String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
for ( int i = 0; i < mappingFiles.length; i++ ) {
cfg.addResource( mappingFiles[i] );
}
if ( customListeners != null && !customListeners.isEmpty() ) {
Iterator entries = customListeners.entrySet().iterator();
while ( entries.hasNext() ) {
final Map.Entry entry = ( Map.Entry ) entries.next();
final String type = ( String ) entry.getKey();
final Object value = entry.getValue();
if ( value != null ) {
if ( String.class.isAssignableFrom( value.getClass() ) ) {
// Its the listener class name
cfg.setListener( type, ( ( String ) value ) );
}
else {
// Its the listener instance (or better be)
cfg.setListener( type, value );
}
}
}
}
return cfg;
|
protected final java.util.Properties | buildProperties()
Properties props = new Properties();
setUnlessNull( props, Environment.DIALECT, dialect );
setUnlessNull( props, Environment.DEFAULT_SCHEMA, defaultSchema );
setUnlessNull( props, Environment.DEFAULT_CATALOG, defaultCatalog );
setUnlessNull( props, Environment.MAX_FETCH_DEPTH, maximumFetchDepth );
setUnlessNull( props, Environment.STATEMENT_FETCH_SIZE, jdbcFetchSize );
setUnlessNull( props, Environment.STATEMENT_BATCH_SIZE, jdbcBatchSize );
setUnlessNull( props, Environment.BATCH_VERSIONED_DATA, batchVersionedDataEnabled );
setUnlessNull( props, Environment.USE_SCROLLABLE_RESULTSET, jdbcScrollableResultSetEnabled );
setUnlessNull( props, Environment.USE_GET_GENERATED_KEYS, getGeneratedKeysEnabled );
setUnlessNull( props, Environment.USE_STREAMS_FOR_BINARY, streamsForBinaryEnabled );
setUnlessNull( props, Environment.USE_REFLECTION_OPTIMIZER, reflectionOptimizationEnabled );
setUnlessNull( props, Environment.QUERY_SUBSTITUTIONS, querySubstitutions );
setUnlessNull( props, Environment.SHOW_SQL, showSqlEnabled );
setUnlessNull( props, Environment.USE_SQL_COMMENTS, commentsEnabled );
setUnlessNull( props, Environment.CACHE_PROVIDER, cacheProviderClass );
setUnlessNull( props, Environment.CACHE_PROVIDER_CONFIG, cacheProviderConfig );
setUnlessNull( props, Environment.CACHE_REGION_PREFIX, cacheRegionPrefix );
setUnlessNull( props, Environment.USE_MINIMAL_PUTS, minimalPutsEnabled );
setUnlessNull( props, Environment.USE_SECOND_LEVEL_CACHE, secondLevelCacheEnabled );
setUnlessNull( props, Environment.USE_QUERY_CACHE, queryCacheEnabled );
Map extraProperties = getExtraProperties();
if ( extraProperties != null ) {
addAll( props, extraProperties );
}
if ( additionalProperties != null ) {
addAll( props, additionalProperties );
}
return props;
|
public final java.lang.String | getBatchVersionedDataEnabled()
return batchVersionedDataEnabled;
|
public final java.lang.String | getCacheProviderClass()
return cacheProviderClass;
|
public java.lang.String | getCacheProviderConfig()
return cacheProviderConfig;
|
public final java.lang.String | getCacheRegionPrefix()
return cacheRegionPrefix;
|
public final java.lang.String | getCommentsEnabled()
return commentsEnabled;
|
public final java.util.Map | getCustomListeners()
return customListeners;
|
public final java.lang.String | getDefaultCatalog()
return defaultCatalog;
|
public final java.lang.String | getDefaultSchema()
return defaultSchema;
|
public final java.lang.String | getDialect()
return dialect;
|
protected java.util.Set | getExcludedPropertyNames()
return excludedPropertyNames;
|
protected java.util.Map | getExtraProperties()
return null;
|
public final java.lang.String | getGetGeneratedKeysEnabled()
return getGeneratedKeysEnabled;
|
public final java.lang.String | getJdbcBatchSize()
return jdbcBatchSize;
|
public final java.lang.String | getJdbcFetchSize()
return jdbcFetchSize;
|
public final java.lang.String | getJdbcScrollableResultSetEnabled()
return jdbcScrollableResultSetEnabled;
|
public final java.lang.String | getMapResources()
return mapResources;
|
public final java.lang.String | getMaximumFetchDepth()
return maximumFetchDepth;
|
public final java.lang.String | getMinimalPutsEnabled()
return minimalPutsEnabled;
|
public final java.lang.String | getQueryCacheEnabled()
return queryCacheEnabled;
|
public final java.lang.String | getQuerySubstitutions()
return querySubstitutions;
|
public final java.lang.String | getReflectionOptimizationEnabled()
return reflectionOptimizationEnabled;
|
public final java.lang.String | getSecondLevelCacheEnabled()
return secondLevelCacheEnabled;
|
public final java.lang.String | getShowSqlEnabled()
return showSqlEnabled;
|
public final java.lang.String | getStreamsForBinaryEnabled()
return streamsForBinaryEnabled;
|
public final void | setBatchVersionedDataEnabled(java.lang.String batchVersionedDataEnabled)
this.batchVersionedDataEnabled = batchVersionedDataEnabled;
|
public final void | setCacheProviderClass(java.lang.String cacheProviderClass)
this.cacheProviderClass = cacheProviderClass;
|
public void | setCacheProviderConfig(java.lang.String cacheProviderConfig)
this.cacheProviderConfig = cacheProviderConfig;
|
public final void | setCacheRegionPrefix(java.lang.String cacheRegionPrefix)
this.cacheRegionPrefix = cacheRegionPrefix;
|
public final void | setCommentsEnabled(java.lang.String commentsEnabled)
this.commentsEnabled = commentsEnabled;
|
public void | setCustomListener(java.lang.String type, java.lang.String listenerClass)
if ( customListeners == null ) {
customListeners = new HashMap();
}
customListeners.put( type, listenerClass );
|
public void | setCustomListeners(java.util.Map customListeners)
this.customListeners = customListeners;
|
public void | setCustomListenersAsString(java.lang.String customListenersString)
// Note : expected in the syntax:
// type=listenerClass
// ({sep}type=listenerClass)*
// where {sep} is any whitespace or comma
if ( StringHelper.isNotEmpty( customListenersString) ) {
String[] listenerEntries = PropertiesHelper.toStringArray( customListenersString, " ,\n\t\r\f" );
for ( int i = 0; i < listenerEntries.length; i++ ) {
final int keyValueSepPosition = listenerEntries[i].indexOf( '=" );
final String type = listenerEntries[i].substring( 0, keyValueSepPosition );
final String listenerClass = listenerEntries[i].substring( keyValueSepPosition + 1 );
setCustomListener( type, listenerClass );
}
}
|
public final void | setDefaultCatalog(java.lang.String defaultCatalog)
this.defaultCatalog = defaultCatalog;
|
public final void | setDefaultSchema(java.lang.String defaultSchema)
this.defaultSchema = defaultSchema;
|
public final void | setDialect(java.lang.String dialect)
this.dialect = dialect;
|
public final void | setGetGeneratedKeysEnabled(java.lang.String getGeneratedKeysEnabled)
this.getGeneratedKeysEnabled = getGeneratedKeysEnabled;
|
public final void | setJdbcBatchSize(java.lang.String jdbcBatchSize)
verifyInt( jdbcBatchSize );
this.jdbcBatchSize = jdbcBatchSize;
|
public final void | setJdbcFetchSize(java.lang.String jdbcFetchSize)
verifyInt( jdbcFetchSize );
this.jdbcFetchSize = jdbcFetchSize;
|
public final void | setJdbcScrollableResultSetEnabled(java.lang.String jdbcScrollableResultSetEnabled)
this.jdbcScrollableResultSetEnabled = jdbcScrollableResultSetEnabled;
|
public final void | setMapResources(java.lang.String mapResources)
this.mapResources = mapResources;
|
public final void | setMaximumFetchDepth(java.lang.String maximumFetchDepth)
verifyInt( maximumFetchDepth );
this.maximumFetchDepth = maximumFetchDepth;
|
public final void | setMinimalPutsEnabled(java.lang.String minimalPutsEnabled)
this.minimalPutsEnabled = minimalPutsEnabled;
|
public final void | setQueryCacheEnabled(java.lang.String queryCacheEnabled)
this.queryCacheEnabled = queryCacheEnabled;
|
public final void | setQuerySubstitutions(java.lang.String querySubstitutions)
this.querySubstitutions = querySubstitutions;
|
public final void | setReflectionOptimizationEnabled(java.lang.String reflectionOptimizationEnabled)
this.reflectionOptimizationEnabled = reflectionOptimizationEnabled;
|
public final void | setSecondLevelCacheEnabled(java.lang.String secondLevelCacheEnabled)
this.secondLevelCacheEnabled = secondLevelCacheEnabled;
|
public final void | setShowSqlEnabled(java.lang.String showSqlEnabled)
this.showSqlEnabled = showSqlEnabled;
|
public final void | setStreamsForBinaryEnabled(java.lang.String streamsForBinaryEnabled)
this.streamsForBinaryEnabled = streamsForBinaryEnabled;
|
private void | setUnlessNull(java.util.Properties props, java.lang.String key, java.lang.String value)
if ( value != null ) {
props.setProperty( key, value );
}
|
private void | verifyInt(java.lang.String value)
if ( value != null ) {
Integer.parseInt( value );
}
|