HHH-7725 - Make handling multi-table bulk HQL operations more pluggable
This commit is contained in:
parent
3e3b439e02
commit
c94752d243
|
@ -312,6 +312,23 @@ public abstract class Dialect implements ConversionContext {
|
|||
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
|
||||
* column length. <tt>$l</tt> in the type name with be replaced by the
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.sql.Connection;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -212,7 +213,10 @@ public class PersistentTableBulkIdStrategy implements MultiTableBulkIdStrategy {
|
|||
return new TableBasedDeleteHandlerImpl( factory, walker ) {
|
||||
@Override
|
||||
protected String extraIdSelectValues() {
|
||||
return "cast(? as char)";
|
||||
final Dialect dialect = factory().getDialect();
|
||||
return dialect.requiresCastingOfParametersInSelectClause()
|
||||
? dialect.cast( "?", Types.CHAR, 36 )
|
||||
: "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue