private static Dialect determineDialect() { try { return Dialect.getDialect(); } catch (Exception e) { return new Dialect() { }; } }
@Override public boolean isMatch() { return !( Dialect.getDialect() instanceof SpatialDialect ); } }
/** * Get an instance of the dialect specified by the given properties or by * the current <tt>System</tt> properties. * * @param props The properties to use for finding the dialect class to use. * @return The specified Dialect * @throws HibernateException If no dialect was specified, or if it could not be instantiated. */ public static Dialect getDialect(Properties props) throws HibernateException { final String dialectName = props.getProperty( Environment.DIALECT ); if ( dialectName == null ) { return getDialect(); } return instantiateDialect( dialectName ); }
public ConnectionLeakUtil() { for ( IdleConnectionCounter connectionCounter : idleConnectionCounters ) { if ( connectionCounter.appliesTo( Dialect.getDialect().getClass() ) ) { this.connectionCounter = connectionCounter; break; } } if ( connectionCounter != null ) { connectionLeakCount = countConnectionLeaks(); } }
if ( Dialect.getDialect() instanceof PostgreSQL81Dialect ) { try (Statement st = connection.createStatement()) { else if( Dialect.getDialect() instanceof MySQLDialect ) { try (PreparedStatement st = connection.prepareStatement("SET SESSION innodb_lock_wait_timeout = ?")) { st.setLong( 1, TimeUnit.MILLISECONDS.toSeconds( millis ) ); else if( Dialect.getDialect() instanceof H2Dialect ) { try (PreparedStatement st = connection.prepareStatement("SET LOCK_TIMEOUT ?")) { st.setLong( 1, millis / 10 ); else if( Dialect.getDialect() instanceof SQLServerDialect ) { try (Statement st = connection.createStatement()) { else if( Dialect.getDialect() instanceof AbstractHANADialect ) { try (Statement st = connection.createStatement()) {
private boolean doesDialectSupportDropTableIfExist() { return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect() .supportsIfExistsBeforeTableName(); }
@After public void tearsDown() { if(!SQLServerDialect.class.isAssignableFrom( Dialect.getDialect().getClass() )) { return; } new SchemaExport().setHaltOnError( true ) .setOutputFile( output.getAbsolutePath() ) .setFormat( false ) .drop( EnumSet.of( TargetType.DATABASE ), metadata ); StandardServiceRegistryBuilder.destroy( ssr ); }
if ( getDialect().qualifyIndexName() ) { indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedNameImpl(
@Test public void testSchemaUpdateAndValidation() throws Exception { if(!SQLServerDialect.class.isAssignableFrom( Dialect.getDialect().getClass() )) { return; } new SchemaUpdate().setHaltOnError( true ) .execute( EnumSet.of( TargetType.DATABASE ), metadata ); new SchemaValidator().validate( metadata ); new SchemaUpdate().setHaltOnError( true ) .setOutputFile( output.getAbsolutePath() ) .setFormat( false ) .execute( EnumSet.of( TargetType.DATABASE, TargetType.SCRIPT ), metadata ); final String fileContent = new String( Files.readAllBytes( output.toPath() ) ); assertThat( "The update output file should be empty", fileContent, is( "" ) ); }
public static StandardServiceRegistryBuilder getStandardServiceRegistryBuilder() { final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder() .configure( "hibernate-config/hibernate.cfg.xml" ) .applySetting( AvailableSettings.GENERATE_STATISTICS, "true" ) .applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE ) .applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" ); if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) { ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc;MVCC=true" ); } return ssrb; }
public static StandardServiceRegistryBuilder getStandardServiceRegistryBuilder() { final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder() .configure( "hibernate-config/hibernate.cfg.xml" ) .applySetting( AvailableSettings.GENERATE_STATISTICS, "true" ) .applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE ) .applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" ); if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) { ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc;MVCC=true" ); } return ssrb; }
@Override public void configure(Configuration cfg) { super.configure( cfg ); if ( !useAntlrParser ) { cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() ); try { String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true ); // if this call succeeds, then the dialect is saying to represent true/false as int values... Integer.parseInt( dialectTrueRepresentation ); String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS ); if ( subs == null ) { subs = ""; } if ( StringHelper.isEmpty( subs ) ) { subs = "true=1, false=0"; } else { subs += ", true=1, false=0"; } cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs ); // cfg.setNamingStrategy( DefaultNamingStrategy.INSTANCE ); } catch( NumberFormatException nfe ) { // the Integer#parseInt call failed... } } cfg.setProperty( AvailableSettings.JDBC_TYLE_PARAMS_ZERO_BASE, "true" ); }
public void testTemporalType() throws Exception { final ZoneId zoneId = ( Dialect.getDialect() instanceof MySQL8Dialect ) ? ZoneId.of( "UTC") : ZoneId.systemDefault();
@Before public void setUp() throws IOException { if(!SQLServerDialect.class.isAssignableFrom( Dialect.getDialect().getClass() )) { return;
String newUrl = tokens[0] + databaseNameToken + DATABASE_NAME; Dialect dialect = Dialect.getDialect();
@Before @SuppressWarnings("unused") public void acquireResources() { final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder() .configure( "hibernate-config/hibernate.cfg.xml" ); if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) { ssrb.applySetting( AvailableSettings.URL, "jdbc:h2:mem:db-mvcc;MVCC=true" ); } ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" ); serviceRegistry = ssrb .configure( "hibernate-config/hibernate.cfg.xml" ) .applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE ) .build(); final MetadataSources metadataSources = new MetadataSources( serviceRegistry ); metadataSources.addAnnotatedClass( ReadWriteCacheableItem.class ); metadataSources.addAnnotatedClass( ReadWriteVersionedCacheableItem.class ); metadataSources.addAnnotatedClass( NonStrictReadWriteCacheableItem.class ); metadataSources.addAnnotatedClass( NonStrictReadWriteVersionedCacheableItem.class ); final Metadata metadata = metadataSources.buildMetadata(); TestHelper.createRegions( metadata, true ); sessionFactory = (SessionFactoryImplementor) metadata.buildSessionFactory(); }
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(); }
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 ); }
public SchemaUpdate(Configuration configuration, Properties properties) throws HibernateException { this.configuration = configuration; this.dialect = Dialect.getDialect( properties ); Properties props = new Properties(); props.putAll( dialect.getDefaultProperties() ); props.putAll( properties ); this.connectionHelper = new ManagedProviderConnectionHelper( props ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); }
public SchemaExport(Configuration cfg, Connection connection) { this.connectionHelper = new SuppliedConnectionHelper( connection ); dialect = Dialect.getDialect( cfg.getProperties() ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); exceptions = new ArrayList(); }