org.hibernate.tool.schema.spi.CommandAcceptanceException Java Examples
The following examples show how to use
org.hibernate.tool.schema.spi.CommandAcceptanceException.
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: FastBootEntityManagerFactoryBuilder.java From quarkus with Apache License 2.0 | 6 votes |
protected PersistenceException persistenceException(String message, Exception cause) { // Provide a comprehensible message if there is an issue with SSL support Throwable t = cause; while (t != null) { if (t instanceof NoSuchAlgorithmException) { message += "Unable to enable SSL support. You might be in the case where you used the `quarkus.ssl.native=false` configuration" + " and SSL was not disabled automatically for your driver."; break; } if (t instanceof CommandAcceptanceException) { message = "Invalid import file. Make sure your statements are valid and properly separated by a semi-colon."; break; } t = t.getCause(); } return new PersistenceException(getExceptionHeader() + message, cause); }
Example #2
Source File: SchemaCreatorImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applySqlString( String sqlString, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) { if ( StringHelper.isEmpty( sqlString ) ) { return; } try { String sqlStringFormatted = formatter.format( sqlString ); for ( GenerationTarget target : targets ) { target.accept( sqlStringFormatted ); } } catch (CommandAcceptanceException e) { options.getExceptionHandler().handleException( e ); } }
Example #3
Source File: AbstractSchemaMigrator.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applySqlString( boolean quiet, String sqlString, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) { if ( !StringHelper.isEmpty( sqlString ) ) { String sqlStringFormatted = formatter.format( sqlString ); for ( GenerationTarget target : targets ) { try { target.accept( sqlStringFormatted ); } catch (CommandAcceptanceException e) { if ( !quiet ) { options.getExceptionHandler().handleException( e ); } // otherwise ignore the exception } } } }
Example #4
Source File: SchemaDropperImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private static void applySqlString( String sqlString, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) { if ( StringHelper.isEmpty( sqlString ) ) { return; } String sqlStringFormatted = formatter.format( sqlString ); for ( GenerationTarget target : targets ) { try { target.accept( sqlStringFormatted ); } catch (CommandAcceptanceException e) { options.getExceptionHandler().handleException( e ); } } }
Example #5
Source File: HibernateExceptionUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void whenWrongDialectSpecified_thenCommandAcceptanceException() { thrown.expect(SchemaManagementException.class); thrown.expectCause(isA(CommandAcceptanceException.class)); thrown.expectMessage("Halting on error : Error executing DDL"); Configuration cfg = getConfiguration(); cfg.setProperty(AvailableSettings.DIALECT, "org.hibernate.dialect.MySQLDialect"); cfg.setProperty(AvailableSettings.HBM2DDL_AUTO, "update"); // This does not work due to hibernate bug // cfg.setProperty(AvailableSettings.HBM2DDL_HALT_ON_ERROR,"true"); cfg.getProperties() .put(AvailableSettings.HBM2DDL_HALT_ON_ERROR, true); cfg.addAnnotatedClass(Product.class); cfg.buildSessionFactory(); }
Example #6
Source File: ExceptionHandlerHaltImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void handleException(CommandAcceptanceException exception) { throw new SchemaManagementException( String.format( Locale.ROOT, "Halting on error : %s", exception.getMessage() ), exception ); }
Example #7
Source File: AbstractScriptTargetOutput.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void accept(String command) { try { writer().write( command ); writer().write( System.lineSeparator() ); writer().flush(); } catch (IOException e) { throw new CommandAcceptanceException( "Could not write \"" + command + "\" to target script file", e ); } }
Example #8
Source File: ExceptionHandlerLoggedImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void handleException(CommandAcceptanceException exception) { log.warnf( exception, "GenerationTarget encountered exception accepting command : %s", exception.getMessage() ); }
Example #9
Source File: SchemaDropperImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void perform(ServiceRegistry serviceRegistry) { log.startingDelayedSchemaDrop(); final JdbcContext jdbcContext = new JdbcContextDelayedDropImpl( serviceRegistry ); final GenerationTargetToDatabase target = new GenerationTargetToDatabase( serviceRegistry.getService( TransactionCoordinatorBuilder.class ).buildDdlTransactionIsolator( jdbcContext ), true ); target.prepare(); try { for ( String command : commands ) { try { target.accept( command ); } catch (CommandAcceptanceException e) { // implicitly we do not "halt on error", but we do want to // report the problem log.unsuccessfulSchemaManagementCommand( command ); log.debugf( e, "Error performing delayed DROP command [%s]", command ); } } } finally { target.release(); } }
Example #10
Source File: ExceptionHandlerCollectingImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void handleException(CommandAcceptanceException exception) { exceptions.add( exception ); }
Example #11
Source File: ExceptionHandlerCollectingImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public List<CommandAcceptanceException> getExceptions() { return exceptions; }