org.hibernate.dialect.PostgreSQL9Dialect Java Examples

The following examples show how to use org.hibernate.dialect.PostgreSQL9Dialect. 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
Source File: DatabaseSchemaUpdateTest.java    From jpa2ddl with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateSchemaFromDatabaseWithUpdateWithPostgresDialect() throws Exception {
	// given
	File outputPath = tempFolder.newFolder();
	Properties jpaProperties = new Properties();
	jpaProperties.setProperty("hibernate.dialect", PostgreSQL9Dialect.class.getCanonicalName());

	SchemaGenerator schemaGenerator = new SchemaGenerator();

	// when
	schemaGenerator.generate(new GeneratorSettings(GenerationMode.DATABASE, outputPath,
			Arrays.asList("com.devskiller.jpa2ddl.sample"), Action.UPDATE, jpaProperties, true, ";", false));

	// then
	String sql = new String(Files.readAllBytes(outputPath.toPath().resolve("v1__jpa2ddl.sql")));
	assertThat(sql).contains("create table User");
	assertThat(sql).doesNotContain("drop table User");
}
 
Example #2
Source File: SqlClientPool.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void configure(Map configurationValues) {
	//TODO: actually extract the configuration values we need rather than keeping a reference to the whole map.
	this.configurationValues = configurationValues;

	showSQL = ConfigurationHelper.getBoolean( Settings.SHOW_SQL, configurationValues, false );
	formatSQL = ConfigurationHelper.getBoolean( Settings.FORMAT_SQL, configurationValues, false );
	usePostgresStyleParameters =
			serviceRegistry.getService(JdbcEnvironment.class).getDialect() instanceof PostgreSQL9Dialect;
}
 
Example #3
Source File: StandAloneReactiveTest.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void createReactiveSessionFactory() {
	StandardServiceRegistry registry = new ReactiveServiceRegistryBuilder()
			.applySetting( Settings.TRANSACTION_COORDINATOR_STRATEGY, "jta" )
			.applySetting( Settings.DIALECT, PostgreSQL9Dialect.class.getName() )
			.build();

	Stage.SessionFactory factory = new MetadataSources( registry )
			.buildMetadata()
			.getSessionFactoryBuilder()
			.build()
			.unwrap( Stage.SessionFactory.class );

	assertThat( factory ).isNotNull();
}
 
Example #4
Source File: MCRHibernateConfigHelper.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
public static void checkEntityManagerFactoryConfiguration(EntityManagerFactory entityManagerFactory) {
    try {
        SessionFactoryImpl sessionFactoryImpl = entityManagerFactory.unwrap(SessionFactoryImpl.class);
        if (PostgreSQL9Dialect.class
            .isInstance(sessionFactoryImpl.getServiceRegistry().getService(JdbcServices.class).getDialect())) {
            //fix ClassLeftUnique and ClassRightUnique, as PostgreSQL cannot evaluate them on statement level
            modifyConstraints(sessionFactoryImpl);
        }
    } catch (PersistenceException e) {
        LogManager.getLogger()
            .warn("Unsupported EntityManagerFactory found: {}", entityManagerFactory.getClass().getName());
    }
}
 
Example #5
Source File: TenancySampleApplication.java    From tenancy-sample with Apache License 2.0 5 votes vote down vote up
public
@Bean
EntityManagerFactory customEntityManagerFactory(DataSource dataSource) {
    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(false); // turn off with Discriminator strategy so far!
    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan(TenancySampleApplication.class.getPackage().getName());
    factory.setDataSource(dataSource);
    factory.getJpaPropertyMap().put(Environment.DIALECT, PostgreSQL9Dialect.class.getName());
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT, MultiTenancyStrategy.DISCRIMINATOR);
    factory.getJpaPropertyMap().put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, new TenantHolder());
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #6
Source File: StrategySelectorBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void addDialects(StrategySelectorImpl strategySelector) {
	addDialect( strategySelector, Cache71Dialect.class );
	addDialect( strategySelector, CUBRIDDialect.class );
	addDialect( strategySelector, DB2Dialect.class );
	addDialect( strategySelector, DB2390Dialect.class );
	addDialect( strategySelector, DB2390V8Dialect.class );
	addDialect( strategySelector, DB2400Dialect.class );
	addDialect( strategySelector, DerbyTenFiveDialect.class );
	addDialect( strategySelector, DerbyTenSixDialect.class );
	addDialect( strategySelector, DerbyTenSevenDialect.class );
	addDialect( strategySelector, FirebirdDialect.class );
	addDialect( strategySelector, FrontBaseDialect.class );
	addDialect( strategySelector, H2Dialect.class );
	addDialect( strategySelector, HANAColumnStoreDialect.class );
	addDialect( strategySelector, HANARowStoreDialect.class );
	addDialect( strategySelector, HSQLDialect.class );
	addDialect( strategySelector, InformixDialect.class );
	addDialect( strategySelector, IngresDialect.class );
	addDialect( strategySelector, Ingres9Dialect.class );
	addDialect( strategySelector, Ingres10Dialect.class );
	addDialect( strategySelector, InterbaseDialect.class );
	addDialect( strategySelector, JDataStoreDialect.class );
	addDialect( strategySelector, MckoiDialect.class );
	addDialect( strategySelector, MimerSQLDialect.class );
	addDialect( strategySelector, MySQL5Dialect.class );
	addDialect( strategySelector, MySQL5InnoDBDialect.class );
	addDialect( strategySelector, MySQL57InnoDBDialect.class );
	addDialect( strategySelector, MySQL57Dialect.class );
	addDialect( strategySelector, Oracle8iDialect.class );
	addDialect( strategySelector, Oracle9iDialect.class );
	addDialect( strategySelector, Oracle10gDialect.class );
	addDialect( strategySelector, PointbaseDialect.class );
	addDialect( strategySelector, PostgresPlusDialect.class );
	addDialect( strategySelector, PostgreSQL81Dialect.class );
	addDialect( strategySelector, PostgreSQL82Dialect.class );
	addDialect( strategySelector, PostgreSQL9Dialect.class );
	addDialect( strategySelector, ProgressDialect.class );
	addDialect( strategySelector, SAPDBDialect.class );
	addDialect( strategySelector, SQLServerDialect.class );
	addDialect( strategySelector, SQLServer2005Dialect.class );
	addDialect( strategySelector, SQLServer2008Dialect.class );
	addDialect( strategySelector, Sybase11Dialect.class );
	addDialect( strategySelector, SybaseAnywhereDialect.class );
	addDialect( strategySelector, SybaseASE15Dialect.class );
	addDialect( strategySelector, SybaseASE157Dialect.class );
	addDialect( strategySelector, TeradataDialect.class );
	addDialect( strategySelector, TimesTenDialect.class );
}
 
Example #7
Source File: PostgreSQLDataSourceProvider.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public String hibernateDialect() {
    return PostgreSQL9Dialect.class.getName();
}
 
Example #8
Source File: HibernateUtil.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static boolean isPostgress() {
	return PostgreSQL9Dialect.class.isAssignableFrom(getDialect());
}
 
Example #9
Source File: HibernateUtil.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static boolean isPostgress(Class dialect) {
	return PostgreSQL9Dialect.class.isAssignableFrom(dialect);
}