DialectFactorypublic class DialectFactory extends Object A factory for generating Dialect instances. |
Fields Summary |
---|
private static final Map | MAPPERS |
Methods Summary |
---|
public static Dialect | buildDialect(java.util.Properties props, java.lang.String databaseName, int databaseMajorVersion)Builds an appropriate Dialect instance.
If a dialect is explicitly named in the incoming properties, it is used. Otherwise, the database name and version
(obtained from connection metadata) are used to make the dertemination.
An exception is thrown if a dialect was not explicitly set and the database name is not known.
String dialectName = props.getProperty( Environment.DIALECT );
if ( dialectName == null ) {
return determineDialect( databaseName, databaseMajorVersion );
}
else {
return buildDialect( dialectName );
}
| public static Dialect | buildDialect(java.lang.String dialectName)Returns a dialect instance given the name of the class to use.
try {
return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
}
catch ( ClassNotFoundException cnfe ) {
throw new HibernateException( "Dialect class not found: " + dialectName );
}
catch ( Exception e ) {
throw new HibernateException( "Could not instantiate dialect class", e );
}
| public static Dialect | determineDialect(java.lang.String databaseName, int databaseMajorVersion)Determine the appropriate Dialect to use given the database product name
and major version.
if ( databaseName == null ) {
throw new HibernateException( "Hibernate Dialect must be explicitly set" );
}
DatabaseDialectMapper mapper = ( DatabaseDialectMapper ) MAPPERS.get( databaseName );
if ( mapper == null ) {
throw new HibernateException( "Hibernate Dialect must be explicitly set for database: " + databaseName );
}
String dialectName = mapper.getDialectClass( databaseMajorVersion );
return buildDialect( dialectName );
|
|