本文整理了Java中org.hibernate.engine.jdbc.internal.Formatter
类的一些代码示例,展示了Formatter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter
类的具体详情如下:
包路径:org.hibernate.engine.jdbc.internal.Formatter
类名称:Formatter
[英]Formatter contract
[中]格式合同
代码示例来源:origin: hibernate/hibernate-orm
@Override
public void accept(String action) {
if (formatter != null) {
action = formatter.format(action);
}
if ( delimiter != null ) {
action += delimiter;
}
System.out.println( action );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Log a SQL statement string using the specified formatter
*
* @param statement The SQL statement.
* @param formatter The formatter to use.
*/
@AllowSysOut
public void logStatement(String statement, Formatter formatter) {
if ( format ) {
if ( logToStdout || LOG.isDebugEnabled() ) {
statement = formatter.format( statement );
}
}
LOG.debug( statement );
if ( logToStdout ) {
System.out.println( "Hibernate: " + statement );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
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 );
}
}
代码示例来源:origin: hibernate/hibernate-orm
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 );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
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
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void assertNoLoss(String query) {
String formattedQuery = FormatStyle.BASIC.getFormatter().format( query );
StringTokenizer formatted = new StringTokenizer( formattedQuery, " \t\n\r\f()" );
StringTokenizer plain = new StringTokenizer( query, " \t\n\r\f()" );
log.debugf( "Original: {}", query );
log.debugf( "Formatted: {}", formattedQuery );
while ( formatted.hasMoreTokens() && plain.hasMoreTokens() ) {
String plainToken = plain.nextToken();
String formattedToken = formatted.nextToken();
assertEquals( "formatter did not return the same token", plainToken, formattedToken );
}
assertFalse( formatted.hasMoreTokens() );
assertFalse( plain.hasMoreTokens() );
}
}
代码示例来源:origin: geowarin/hibernate-examples
private void write(PrintWriter writer, String[] lines, Formatter formatter) {
for (String string : lines)
writer.println(formatter.format(string) + ";");
}
代码示例来源:origin: xpinjection/hibernate-basics
@Override
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql) {
if (sql.isEmpty()) {
return "";
}
String batch = "batch".equals(category) ? " add to batch " : "";
return String.format("Hibernate: %s %s {elapsed: %dms}", batch, HIBERNATE_SQL_FORMATTER.format(sql), elapsed);
}
}
代码示例来源:origin: xpinjection/hibernate-performance
@Override
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql) {
if (sql.isEmpty()) {
return "";
}
String batch = "batch".equals(category) ? " add to batch " : "";
return String.format("Hibernate: %s %s {elapsed: %dms}", batch, HIBERNATE_SQL_FORMATTER.format(sql), elapsed);
}
}
代码示例来源:origin: org.camunda.bpm.cycle/camunda-cycle-sql-scripts
private static void export(File outFile, String delimiter, Formatter formatter, String[] createSQL) {
PrintWriter writer = null;
try {
writer = new PrintWriter(outFile);
for (String string : createSQL) {
writer.print(formatter.format(string) + "\n" + delimiter + "\n");
}
} catch (FileNotFoundException e) {
System.err.println(e);
} finally {
if (writer != null)
writer.close();
}
}
代码示例来源:origin: org.opensingular/singular-app-commons
/**
* Method reponsible to formmat the script, should skip line, and put the DDL and DML scripts.
*
* @param scriptsEntities the script of the entities generated by hibernate.
* @param scriptsAdicionais some extra scripts, normally DML scripts.
* @return A StringBuilder containg all DML and DDL scripts.
*/
private static StringBuilder formatterScript(String[] scriptsEntities, StringBuilder scriptsAdicionais) {
Formatter formatter = FormatStyle.DDL.getFormatter();
StringBuilder stringSql = new StringBuilder();
for (String string : scriptsEntities) {
String lineFormated = formatter.format(string) + "; \n";
stringSql.append(lineFormated);
}
if (scriptsAdicionais != null) {
stringSql.append(scriptsAdicionais);
}
return stringSql;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public void logStatement(String statement, Formatter formatter) {
if ( format ) {
if ( logToStdout || LOG.isDebugEnabled() ) {
statement = formatter.format( statement );
}
}
LOG.debug( statement );
if ( logToStdout ) {
System.out.println( "Hibernate: " + statement );
}
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public void logStatement(String statement, Formatter formatter) {
if ( format ) {
if ( logToStdout || LOG.isDebugEnabled() ) {
statement = formatter.format( statement );
}
}
LOG.debug( statement );
if ( logToStdout ) {
System.out.println( "Hibernate: " + statement );
}
}
}
代码示例来源:origin: org.hibernate.orm/hibernate-core
/**
* Log a SQL statement string using the specified formatter
*
* @param statement The SQL statement.
* @param formatter The formatter to use.
*/
@AllowSysOut
public void logStatement(String statement, Formatter formatter) {
if ( format ) {
if ( logToStdout || LOG.isDebugEnabled() ) {
statement = formatter.format( statement );
}
}
LOG.debug( statement );
if ( logToStdout ) {
System.out.println( "Hibernate: " + statement );
}
}
}
代码示例来源:origin: sismics/reader
String formatted = formatter.format(transformed);
try {
log.debug(formatted);
代码示例来源:origin: de.alpharogroup/dao.api
sb.append(formatter.format(result));
sb.append(formatter.format(result));
代码示例来源:origin: de.alpharogroup/data-initialization
sb.append(formatter.format(schemaString));
sb.append(System.getProperty("line.separator"));
sb.append(System.getProperty("line.separator"));
代码示例来源:origin: Jasig/uPortal
try {
for (final String sqlCommand : sqlCommands) {
final String formatted = formatter.format(sqlCommand);
sqlWriter.println(formatted);
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private void execute(boolean script, boolean export, Writer fileOutput, Statement statement, final String sql)
throws IOException, SQLException {
final SqlExceptionHelper sqlExceptionHelper = new SqlExceptionHelper();
String formatted = formatter.format( sql );
if (delimiter != null) formatted += delimiter;
if (script) System.out.println(formatted);
LOG.debug(formatted);
if ( outputFile != null ) {
fileOutput.write( formatted + "\n" );
}
if ( export ) {
statement.executeUpdate( sql );
try {
SQLWarning warnings = statement.getWarnings();
if ( warnings != null) {
sqlExceptionHelper.logAndClearWarnings( connectionHelper.getConnection() );
}
}
catch( SQLException sqle ) {
LOG.unableToLogSqlWarnings(sqle);
}
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private void perform(String[] sqlCommands, List<Exporter> exporters) {
for ( String sqlCommand : sqlCommands ) {
String formatted = formatter.format( sqlCommand );
if ( delimiter != null ) {
formatted += delimiter;
}
sqlStatementLogger.logStatement( sqlCommand, formatter );
for ( Exporter exporter : exporters ) {
try {
exporter.export( formatted );
}
catch (Exception e) {
if ( haltOnError ) {
throw new HibernateException( "Error during DDL export", e );
}
exceptions.add( e );
LOG.unsuccessfulCreate( sqlCommand );
LOG.error( e.getMessage() );
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!