Java Code Examples for org.hibernate.engine.jdbc.spi.SqlExceptionHelper

The following examples show how to use org.hibernate.engine.jdbc.spi.SqlExceptionHelper. 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
Source Project: herd   Source File: StorageServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Ignore
@Test(expected = PersistenceException.class)
public void testDeleteStorageConstraintViolation() throws Exception
{
    // Create a storage unit entity that refers to a newly created storage.
    final StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper
        .createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE,
            SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, NO_STORAGE_DIRECTORY_PATH);

    executeWithoutLogging(SqlExceptionHelper.class, new Command()
    {
        @Override
        public void execute()
        {
            // Delete the storage which is invalid because there still exists a storage unit entity that references it.
            StorageKey alternateKey = new StorageKey(storageUnitEntity.getStorage().getName());
            storageService.deleteStorage(alternateKey);
        }
    });
}
 
Example 2
@Test(expected = PersistenceException.class)
public void testCreateBusinessObjectDataAttributeValueTooLarge() throws Exception
{
    final BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();

    // Create and add a duplicate attribute which is not allowed.
    Attribute newAttribute = new Attribute();
    newAttribute.setName("Valid Name");
    newAttribute.setValue(new String(new char[4001]).replace('\0', 'A')); // Test value greater than 4000 byte limit.
    businessObjectDataCreateRequest.getAttributes().add(newAttribute);

    executeWithoutLogging(SqlExceptionHelper.class, new Command()
    {
        @Override
        public void execute()
        {
            // Create the business object data which is invalid.
            businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
        }
    });
}
 
Example 3
Source Project: lams   Source File: JtaIsolationDelegate.java    License: GNU General Public License v2.0 5 votes vote down vote up
public JtaIsolationDelegate(
		JdbcConnectionAccess connectionAccess,
		SqlExceptionHelper sqlExceptionHelper,
		TransactionManager transactionManager) {
	this.connectionAccess = connectionAccess;
	this.sqlExceptionHelper = sqlExceptionHelper;
	this.transactionManager = transactionManager;
}
 
Example 4
Source Project: lams   Source File: DatabaseExporter.java    License: GNU General Public License v2.0 5 votes vote down vote up
public DatabaseExporter(ConnectionHelper connectionHelper, SqlExceptionHelper sqlExceptionHelper) throws SQLException {
	this.connectionHelper = connectionHelper;
	this.sqlExceptionHelper = sqlExceptionHelper;

	connectionHelper.prepare( true );
	connection = connectionHelper.getConnection();
	statement = connection.createStatement();
}
 
Example 5
private JdbcContextImpl(
		JdbcConnectionAccess jdbcConnectionAccess,
		Dialect dialect,
		SqlStatementLogger sqlStatementLogger,
		SqlExceptionHelper sqlExceptionHelper,
		ServiceRegistry serviceRegistry) {
	this.jdbcConnectionAccess = jdbcConnectionAccess;
	this.dialect = dialect;
	this.sqlStatementLogger = sqlStatementLogger;
	this.sqlExceptionHelper = sqlExceptionHelper;
	this.serviceRegistry = serviceRegistry;
}
 
Example 6
Source Project: lams   Source File: JdbcEnvironmentImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) {
	final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter();
	sqlExceptionConverter.addDelegate( dialect.buildSQLExceptionConversionDelegate() );
	sqlExceptionConverter.addDelegate( new SQLExceptionTypeDelegate( dialect ) );
	// todo : vary this based on extractedMetaDataSupport.getSqlStateType()
	sqlExceptionConverter.addDelegate( new SQLStateConversionDelegate( dialect ) );
	return new SqlExceptionHelper( sqlExceptionConverter, logWarnings );
}
 
Example 7
Source Project: lams   Source File: JdbcServicesImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	if ( jdbcEnvironment != null ) {
		return jdbcEnvironment.getSqlExceptionHelper();
	}
	return null;
}
 
Example 8
@Override @SuppressWarnings("unchecked")
public <R extends Service> R getService(Class<R> serviceRole) {
    if ( serviceRole == VertxInstance.class ) {
        return (R) vertxService;
    }
    else if ( serviceRole == JdbcEnvironment.class ) {
        return (R) new JdbcEnvironment() {
            @Override
            public Dialect getDialect() {
                return new MySQL8Dialect();
            }

            @Override
            public ExtractedDatabaseMetaData getExtractedDatabaseMetaData() {
                return null;
            }

            @Override
            public Identifier getCurrentCatalog() {
                return null;
            }

            @Override
            public Identifier getCurrentSchema() {
                return null;
            }

            @Override
            public QualifiedObjectNameFormatter getQualifiedObjectNameFormatter() {
                return null;
            }

            @Override
            public IdentifierHelper getIdentifierHelper() {
                return null;
            }

            @Override
            public NameQualifierSupport getNameQualifierSupport() {
                return null;
            }

            @Override
            public SqlExceptionHelper getSqlExceptionHelper() {
                return null;
            }

            @Override
            public LobCreatorBuilder getLobCreatorBuilder() {
                return null;
            }

            @Override
            public TypeInfo getTypeInfoForJdbcCode(int jdbcTypeCode) {
                return null;
            }
        };
    }
    else {
        throw new IllegalArgumentException( "This is a mock service - need to explicitly handle any service we might need during testing" );
    }
}
 
Example 9
Source Project: lams   Source File: JdbcIsolationDelegate.java    License: GNU General Public License v2.0 4 votes vote down vote up
public JdbcIsolationDelegate(JdbcConnectionAccess connectionAccess, SqlExceptionHelper sqlExceptionHelper) {
	this.connectionAccess = connectionAccess;
	this.sqlExceptionHelper = sqlExceptionHelper;
}
 
Example 10
Source Project: lams   Source File: JdbcIsolationDelegate.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected SqlExceptionHelper sqlExceptionHelper() {
	return this.sqlExceptionHelper;
}
 
Example 11
Source Project: lams   Source File: JtaIsolationDelegate.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected SqlExceptionHelper sqlExceptionHelper() {
	return this.sqlExceptionHelper;
}
 
Example 12
protected SqlExceptionHelper getSQLExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example 13
public SuppliedConnectionProviderConnectionHelper(ConnectionProvider provider, SqlExceptionHelper sqlExceptionHelper)  {
	this.provider = provider;
	this.sqlExceptionHelper = sqlExceptionHelper;
}
 
Example 14
public SuppliedConnectionHelper(Connection connection, SqlExceptionHelper sqlExceptionHelper) {
	this.connection = connection;
	this.sqlExceptionHelper = sqlExceptionHelper;
}
 
Example 15
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example 16
Source Project: lams   Source File: SchemaDropperImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return jdbcServices.getSqlExceptionHelper();
}
 
Example 17
Source Project: lams   Source File: JdbcEnvironmentImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example 18
Source Project: lams   Source File: StatementPreparerImpl.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected final SqlExceptionHelper sqlExceptionHelper() {
	return getJdbcService().getSqlExceptionHelper();
}
 
Example 19
@Override
public SqlExceptionHelper getSQLExceptionHelper() {
	return delegate.getSQLExceptionHelper();
}
 
Example 20
Source Project: lemon   Source File: SessionFactoryWrapper.java    License: Apache License 2.0 4 votes vote down vote up
public SqlExceptionHelper getSQLExceptionHelper() {
    return sessionFactoryImplementor.getSQLExceptionHelper();
}
 
Example 21
Source Project: lams   Source File: JdbcEnvironment.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Obtain the helper for dealing with JDBC {@link java.sql.SQLException} faults.
 *
 * @return This environment's helper.
 */
SqlExceptionHelper getSqlExceptionHelper();
 
Example 22
Source Project: lams   Source File: JdbcCoordinatorImpl.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Access to the SqlExceptionHelper
 *
 * @return The SqlExceptionHelper
 */
public SqlExceptionHelper sqlExceptionHelper() {
	return exceptionHelper;
}
 
Example 23
Source Project: lams   Source File: AbstractBatchImpl.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convenience access to the SQLException helper.
 *
 * @return The underlying SQLException helper.
 */
protected SqlExceptionHelper sqlExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example 24
/**
 * Retrieves the SqlExceptionHelper in effect for this SessionFactory.
 *
 * @return The SqlExceptionHelper for this SessionFactory.
 *
 * @deprecated since 5.0; use {@link JdbcServices#getSqlExceptionHelper()} instead as
 * obtained from {@link #getServiceRegistry()}
 */
@Deprecated
default SqlExceptionHelper getSQLExceptionHelper() {
	return getServiceRegistry().getService( JdbcServices.class ).getSqlExceptionHelper();
}
 
Example 25
Source Project: lams   Source File: JdbcContext.java    License: GNU General Public License v2.0 votes vote down vote up
SqlExceptionHelper getSqlExceptionHelper();