HHH-7725 - Make handling multi-table bulk HQL operations more pluggable

This commit is contained in:
Steve Ebersole 2012-10-30 14:02:53 -05:00
parent 3e3b439e02
commit c94752d243
2 changed files with 22 additions and 1 deletions

View File

@ -312,6 +312,23 @@ public abstract class Dialect implements ConversionContext {
return getTypeName( code, Column.DEFAULT_LENGTH, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE ); return getTypeName( code, Column.DEFAULT_LENGTH, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE );
} }
public String cast(String value, int jdbcTypeCode, int length, int precision, int scale) {
if ( jdbcTypeCode == Types.CHAR ) {
return "cast(" + value + " as char(" + length + "))";
}
else {
return "cast(" + value + "as " + getTypeName( jdbcTypeCode, length, precision, scale ) + ")";
}
}
public String cast(String value, int jdbcTypeCode, int length) {
return cast( value, jdbcTypeCode, length, Column.DEFAULT_PRECISION, Column.DEFAULT_SCALE );
}
public String cast(String value, int jdbcTypeCode, int precision, int scale) {
return cast( value, jdbcTypeCode, Column.DEFAULT_LENGTH, precision, scale );
}
/** /**
* Subclasses register a type name for the given type code and maximum * Subclasses register a type name for the given type code and maximum
* column length. <tt>$l</tt> in the type name with be replaced by the * column length. <tt>$l</tt> in the type name with be replaced by the

View File

@ -27,6 +27,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -212,7 +213,10 @@ public class PersistentTableBulkIdStrategy implements MultiTableBulkIdStrategy {
return new TableBasedDeleteHandlerImpl( factory, walker ) { return new TableBasedDeleteHandlerImpl( factory, walker ) {
@Override @Override
protected String extraIdSelectValues() { protected String extraIdSelectValues() {
return "cast(? as char)"; final Dialect dialect = factory().getDialect();
return dialect.requiresCastingOfParametersInSelectClause()
? dialect.cast( "?", Types.CHAR, 36 )
: "?";
} }
@Override @Override