Java Code Examples for org.hibernate.dialect.Dialect#getDialect()

The following examples show how to use org.hibernate.dialect.Dialect#getDialect() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private FumCompositeID fumKey(String str, boolean aCompositeQueryTest) {
	FumCompositeID id = new FumCompositeID();
	if ( Dialect.getDialect() instanceof MckoiDialect ) {
		GregorianCalendar now = new GregorianCalendar();
		GregorianCalendar cal = new GregorianCalendar(
			now.get(java.util.Calendar.YEAR),
			now.get(java.util.Calendar.MONTH),
			now.get(java.util.Calendar.DATE)
		);
		id.setDate( cal.getTime() );
	}
	else {
		id.setDate( new Date() );
	}
	id.setString( new String(str) );

	if (aCompositeQueryTest) {
		id.setShort( fumKeyShort++ );
	}
	else {
		id.setShort( (short) 12 );
	}

	return id;
}
 
Example 2
public SchemaUpdate(Configuration cfg, Properties connectionProperties) throws HibernateException {
	this.configuration = cfg;
	dialect = Dialect.getDialect(connectionProperties);
	Properties props = new Properties();
	props.putAll(dialect.getDefaultProperties());
	props.putAll(connectionProperties);
	connectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
	exceptions = new ArrayList<Exception>();
}
 
Example 3
/**
 * Create a schema exporter for the given Configuration, with the given
 * database connection properties.
 *
 * @deprecated properties may be specified via the Configuration object
 */
public SchemaExport(Configuration cfg, Properties properties)
		throws HibernateException {
	dialect = Dialect.getDialect( properties );

	Properties props = new Properties();
	props.putAll( dialect.getDefaultProperties() );
	props.putAll( properties );

	connectionHelper = new ManagedProviderConnectionHelper( props );
	dropSQL = cfg.generateDropSchemaScript( dialect );
	createSQL = cfg.generateSchemaCreationScript( dialect );
	format = PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props );
}
 
Example 4
public SchemaUpdate(Configuration cfg, Properties connectionProperties) throws HibernateException {
	this.configuration = cfg;
	dialect = Dialect.getDialect( connectionProperties );
	Properties props = new Properties();
	props.putAll( dialect.getDefaultProperties() );
	props.putAll( connectionProperties );
	connectionHelper = new ManagedProviderConnectionHelper( props );
	exceptions = new ArrayList();
}
 
Example 5
public SchemaValidator(Configuration cfg, Properties connectionProperties) throws HibernateException {
	this.configuration = cfg;
	dialect = Dialect.getDialect( connectionProperties );
	Properties props = new Properties();
	props.putAll( dialect.getDefaultProperties() );
	props.putAll( connectionProperties );
	connectionHelper = new ManagedProviderConnectionHelper( props );
}
 
Example 6
public SchemaExport(Configuration cfg, Connection connection) {
	this.connectionHelper = new SuppliedConnectionHelper( connection );
	dialect = Dialect.getDialect( cfg.getProperties() );
	dropSQL = cfg.generateDropSchemaScript( dialect );
	createSQL = cfg.generateSchemaCreationScript( dialect );
}
 
Example 7
protected Dialect getDialect() {
	if ( dialect == null ) {
		dialect = Dialect.getDialect();
	}
	return dialect;
}
 
Example 8
private void buildSessionFactory() throws Exception {
	if ( getSessions()!=null ) {
		getSessions().close();
	}

	TestCase.dialect = Dialect.getDialect();
	if ( ! appliesTo( getDialect() ) ) {
		return;
	}

	try {

		TestCase.cfg = new Configuration();
		cfg.setProperty( Environment.CACHE_PROVIDER, "org.hibernate.cache.HashtableCacheProvider" );
		if( recreateSchema() ) {
			cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
		}
		addMappings( getMappings(), cfg );
		configure( cfg );

		if ( getCacheConcurrencyStrategy() != null ) {
			Iterator iter = cfg.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() && overrideCacheStrategy() ) {
					cfg.setCacheConcurrencyStrategy(
							clazz.getEntityName(),
							getCacheConcurrencyStrategy()
						);
				}
			}
			iter = cfg.getCollectionMappings();
			while ( iter.hasNext() ) {
				Collection coll = (Collection) iter.next();
				cfg.setCollectionCacheConcurrencyStrategy(
						coll.getRole(),
						getCacheConcurrencyStrategy()
					);
			}
		}

		// make sure we use the same dialect...
		cfg.setProperty( Environment.DIALECT, TestCase.dialect.getClass().getName() );
		TestCase.sessions = cfg.buildSessionFactory();
		afterSessionFactoryBuilt();
	}
	catch ( Exception e ) {
		e.printStackTrace();
		throw e;
	}
}
 
Example 9
public void configure(Configuration cfg) {
	super.configure( cfg );
	if ( Dialect.getDialect() instanceof OracleDialect ) {
		( (RootClass) cfg.getClassMapping("org.hibernate.test.legacy.Foo") ).setForceDiscriminator(false);
	}
}