org.hibernate.engine.jdbc.dialect.spi.DialectResolver Java Examples
The following examples show how to use
org.hibernate.engine.jdbc.dialect.spi.DialectResolver.
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: DefaultSequenceHandlerRepository.java From pnc with Apache License 2.0 | 5 votes |
@Override public void dropSequence(final String sequenceName) { Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver.resolveDialect(getResolutionInfo(connection)); PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { preparedStatement = connection.prepareStatement(dialect.getDropSequenceStrings(sequenceName)[0]); preparedStatement.execute(); } catch (SQLException e) { throw e; } finally { if (preparedStatement != null) { preparedStatement.close(); } if (resultSet != null) { resultSet.close(); } } } }; Session session = (Session) entityManager.getDelegate(); SessionFactory sessionFactory = session.getSessionFactory(); sessionFactory.getCurrentSession().doWork(work); }
Example #2
Source File: SQLiteMetadataBuilderInitializer.java From md_blockchain with Apache License 2.0 | 5 votes |
@Override public void contribute(MetadataBuilder metadataBuilder, StandardServiceRegistry serviceRegistry) { DialectResolver dialectResolver = serviceRegistry.getService(DialectResolver.class); if (!(dialectResolver instanceof DialectResolverSet)) { logger.warnf("DialectResolver '%s' is not an instance of DialectResolverSet, not registering SQLiteDialect", dialectResolver); return; } ((DialectResolverSet) dialectResolver).addResolver(resolver); }
Example #3
Source File: DefaultSequenceHandlerRepository.java From pnc with Apache License 2.0 | 5 votes |
@Override public boolean sequenceExists(final String sequenceName) { ReturningWork<Boolean> work = new ReturningWork<Boolean>() { @Override public Boolean execute(Connection connection) throws SQLException { DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver.resolveDialect(getResolutionInfo(connection)); PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { preparedStatement = connection.prepareStatement(dialect.getQuerySequencesString()); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { if (sequenceName.equals(resultSet.getString(1))) { return true; } } } catch (SQLException e) { throw e; } finally { if (preparedStatement != null) { preparedStatement.close(); } if (resultSet != null) { resultSet.close(); } } return false; } }; Session session = (Session) entityManager.getDelegate(); SessionFactory sessionFactory = session.getSessionFactory(); return sessionFactory.getCurrentSession().doReturningWork(work); }
Example #4
Source File: DefaultSequenceHandlerRepository.java From pnc with Apache License 2.0 | 5 votes |
@Override public void createSequence(final String sequenceName) { if (sequenceExists(sequenceName)) { return; } Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver.resolveDialect(getResolutionInfo(connection)); PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { preparedStatement = connection .prepareStatement(dialect.getCreateSequenceStrings(sequenceName, 1, 1)[0]); preparedStatement.execute(); } catch (SQLException e) { throw e; } finally { if (preparedStatement != null) { preparedStatement.close(); } if (resultSet != null) { resultSet.close(); } } } }; Session session = (Session) entityManager.getDelegate(); SessionFactory sessionFactory = session.getSessionFactory(); sessionFactory.getCurrentSession().doWork(work); }
Example #5
Source File: DefaultSequenceHandlerRepository.java From pnc with Apache License 2.0 | 5 votes |
@Override public Long getNextID(final String sequenceName) { ReturningWork<Long> maxReturningWork = new ReturningWork<Long>() { @Override public Long execute(Connection connection) throws SQLException { DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver.resolveDialect(getResolutionInfo(connection)); PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { preparedStatement = connection.prepareStatement(dialect.getSequenceNextValString(sequenceName)); resultSet = preparedStatement.executeQuery(); resultSet.next(); return resultSet.getLong(1); } catch (SQLException e) { throw e; } finally { if (preparedStatement != null) { preparedStatement.close(); } if (resultSet != null) { resultSet.close(); } } } }; Session session = (Session) entityManager.getDelegate(); SessionFactory sessionFactory = session.getSessionFactory(); Long maxRecord = sessionFactory.getCurrentSession().doReturningWork(maxReturningWork); return maxRecord; }
Example #6
Source File: DialectResolverInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final DialectResolverSet resolver = new DialectResolverSet(); applyCustomerResolvers( resolver, registry, configurationValues ); resolver.addResolver(StandardDialectResolver.INSTANCE ); return resolver; }
Example #7
Source File: DialectResolverSet.java From lams with GNU General Public License v2.0 | 4 votes |
public DialectResolverSet(List<DialectResolver> resolvers) { this.resolvers = resolvers; }
Example #8
Source File: CoreMessageLogger.java From lams with GNU General Public License v2.0 | 4 votes |
@LogMessage(level = WARN) @Message(value = "Error executing resolver [%s] : %s", id = 316) void unableToExecuteResolver( DialectResolver abstractDialectResolver, String message);
Example #9
Source File: DialectResolverSet.java From lams with GNU General Public License v2.0 | 4 votes |
public DialectResolverSet(DialectResolver... resolvers) { this( Arrays.asList( resolvers ) ); }
Example #10
Source File: J2CacheMessageLogger_$logger.java From J2Cache with Apache License 2.0 | 4 votes |
public final void unableToExecuteResolver(final DialectResolver arg0, final String arg1) { super.log.logf(FQCN, (org.jboss.logging.Logger.Level.WARN), null, unableToExecuteResolver$str(), arg0, arg1); }
Example #11
Source File: DialectResolverSet.java From lams with GNU General Public License v2.0 | 4 votes |
public DialectResolverSet() { this( new ArrayList<DialectResolver>() ); }
Example #12
Source File: DialectResolverInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Class<DialectResolver> getServiceInitiated() { return DialectResolver.class; }
Example #13
Source File: DialectFactoryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void injectServices(ServiceRegistryImplementor serviceRegistry) { this.strategySelector = serviceRegistry.getService( StrategySelector.class ); this.dialectResolver = serviceRegistry.getService( DialectResolver.class ); }
Example #14
Source File: HibernateSchemaManagementTool.java From lams with GNU General Public License v2.0 | 4 votes |
public JdbcContext resolveJdbcContext(Map configurationValues) { final JdbcContextBuilder jdbcContextBuilder = new JdbcContextBuilder( serviceRegistry ); // see if a specific connection has been provided final Connection providedConnection = (Connection) configurationValues.get( HBM2DDL_CONNECTION ); if ( providedConnection != null ) { jdbcContextBuilder.jdbcConnectionAccess = new JdbcConnectionAccessProvidedConnectionImpl( providedConnection ); } // see if a specific Dialect override has been provided... final String explicitDbName = (String) configurationValues.get( AvailableSettings.HBM2DDL_DB_NAME ); if ( StringHelper.isNotEmpty( explicitDbName ) ) { final String explicitDbMajor = (String) configurationValues.get( AvailableSettings.HBM2DDL_DB_MAJOR_VERSION ); final String explicitDbMinor = (String) configurationValues.get( AvailableSettings.HBM2DDL_DB_MINOR_VERSION ); final Dialect indicatedDialect = serviceRegistry.getService( DialectResolver.class ).resolveDialect( new DialectResolutionInfo() { @Override public String getDatabaseName() { return explicitDbName; } @Override public int getDatabaseMajorVersion() { return StringHelper.isEmpty( explicitDbMajor ) ? NO_VERSION : Integer.parseInt( explicitDbMajor ); } @Override public int getDatabaseMinorVersion() { return StringHelper.isEmpty( explicitDbMinor ) ? NO_VERSION : Integer.parseInt( explicitDbMinor ); } @Override public String getDriverName() { return null; } @Override public int getDriverMajorVersion() { return NO_VERSION; } @Override public int getDriverMinorVersion() { return NO_VERSION; } } ); if ( indicatedDialect == null ) { log.debugf( "Unable to resolve indicated Dialect resolution info (%s, %s, %s)", explicitDbName, explicitDbMajor, explicitDbMinor ); } else { jdbcContextBuilder.dialect = indicatedDialect; } } return jdbcContextBuilder.buildJdbcContext(); }
Example #15
Source File: J2CacheMessageLogger_$logger.java From J2Cache with Apache License 2.0 | 4 votes |
public final void unableToExecuteResolver(DialectResolver arg0, String arg1) { super.log.logf(FQCN, Logger.Level.WARN, (Throwable)null, this.unableToExecuteResolver$str(), arg0, arg1); }
Example #16
Source File: DialectResolverSet.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Add a resolver at the end of the underlying resolver list. The resolver added by this method is at lower * priority than any other existing resolvers. * * @param resolver The resolver to add. */ public void addResolver(DialectResolver resolver) { resolvers.add( resolver ); }
Example #17
Source File: DialectResolverSet.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Add a resolver at the beginning of the underlying resolver list. The resolver added by this method is at higher * priority than any other existing resolvers. * * @param resolver The resolver to add. */ public void addResolverAtFirst(DialectResolver resolver) { resolvers.add( 0, resolver ); }
Example #18
Source File: DialectFactoryImpl.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Intended only for use from testing. * * @param dialectResolver The DialectResolver to use */ public void setDialectResolver(DialectResolver dialectResolver) { this.dialectResolver = dialectResolver; }