类org.hibernate.tool.schema.spi.CommandAcceptanceException源码实例Demo

下面列出了怎么用org.hibernate.tool.schema.spi.CommandAcceptanceException的API类实例代码及写法,或者点击链接到github查看源代码。

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);
}
 
源代码2 项目: lams   文件: SchemaCreatorImpl.java
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 );
	}
}
 
源代码3 项目: lams   文件: AbstractSchemaMigrator.java
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
			}
		}
	}
}
 
源代码4 项目: lams   文件: SchemaDropperImpl.java
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 );
		}
	}
}
 
源代码5 项目: tutorials   文件: HibernateExceptionUnitTest.java
@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();
}
 
源代码6 项目: lams   文件: ExceptionHandlerHaltImpl.java
@Override
public void handleException(CommandAcceptanceException exception) {
	throw new SchemaManagementException(
			String.format(
					Locale.ROOT,
					"Halting on error : %s",
					exception.getMessage()
			),
			exception
	);
}
 
源代码7 项目: lams   文件: AbstractScriptTargetOutput.java
@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 );
	}
}
 
源代码8 项目: lams   文件: ExceptionHandlerLoggedImpl.java
@Override
public void handleException(CommandAcceptanceException exception) {
	log.warnf(
			exception,
			"GenerationTarget encountered exception accepting command : %s",
			exception.getMessage()
	);
}
 
源代码9 项目: lams   文件: SchemaDropperImpl.java
@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();
	}
}
 
源代码10 项目: lams   文件: ExceptionHandlerCollectingImpl.java
@Override
public void handleException(CommandAcceptanceException exception) {
	exceptions.add( exception );
}
 
源代码11 项目: lams   文件: ExceptionHandlerCollectingImpl.java
public List<CommandAcceptanceException> getExceptions() {
	return exceptions;
}
 
 类所在包
 同包方法