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

The following examples show how to use org.hibernate.engine.jdbc.spi.SqlExceptionHelper. 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: BusinessObjectDataServiceCreateBusinessObjectDataTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@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 #2
Source File: StorageServiceTest.java    From herd with 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 #3
Source File: JtaIsolationDelegate.java    From lams with 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 File: JdbcServicesImpl.java    From lams with 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 #5
Source File: DatabaseExporter.java    From lams with 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 #6
Source File: HibernateSchemaManagementTool.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 #7
Source File: JdbcEnvironmentImpl.java    From lams with 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 #8
Source File: SchemaDropperImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return jdbcServices.getSqlExceptionHelper();
}
 
Example #9
Source File: SessionFactoryWrapper.java    From lemon with Apache License 2.0 4 votes vote down vote up
public SqlExceptionHelper getSQLExceptionHelper() {
    return sessionFactoryImplementor.getSQLExceptionHelper();
}
 
Example #10
Source File: SessionFactoryDelegatingImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSQLExceptionHelper() {
	return delegate.getSQLExceptionHelper();
}
 
Example #11
Source File: StatementPreparerImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected final SqlExceptionHelper sqlExceptionHelper() {
	return getJdbcService().getSqlExceptionHelper();
}
 
Example #12
Source File: JdbcEnvironmentImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example #13
Source File: TestingRegistryRule.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
@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 #14
Source File: HibernateSchemaManagementTool.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SqlExceptionHelper getSqlExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example #15
Source File: SuppliedConnectionHelper.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SuppliedConnectionHelper(Connection connection, SqlExceptionHelper sqlExceptionHelper) {
	this.connection = connection;
	this.sqlExceptionHelper = sqlExceptionHelper;
}
 
Example #16
Source File: SuppliedConnectionProviderConnectionHelper.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public SuppliedConnectionProviderConnectionHelper(ConnectionProvider provider, SqlExceptionHelper sqlExceptionHelper)  {
	this.provider = provider;
	this.sqlExceptionHelper = sqlExceptionHelper;
}
 
Example #17
Source File: AbstractCollectionPersister.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected SqlExceptionHelper getSQLExceptionHelper() {
	return sqlExceptionHelper;
}
 
Example #18
Source File: JtaIsolationDelegate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected SqlExceptionHelper sqlExceptionHelper() {
	return this.sqlExceptionHelper;
}
 
Example #19
Source File: JdbcIsolationDelegate.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected SqlExceptionHelper sqlExceptionHelper() {
	return this.sqlExceptionHelper;
}
 
Example #20
Source File: JdbcIsolationDelegate.java    From lams with 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 #21
Source File: JdbcEnvironment.java    From lams with 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 File: JdbcCoordinatorImpl.java    From lams with 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 File: AbstractBatchImpl.java    From lams with 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
Source File: SessionFactoryImplementor.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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 File: JdbcContext.java    From lams with GNU General Public License v2.0 votes vote down vote up
SqlExceptionHelper getSqlExceptionHelper();