HHH-18783 some cleanups, and leave a big TODO
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
050da72ae9
commit
18ccd6ed80
|
@ -401,5 +401,4 @@ public class MariaDBSqlAstTranslator<T extends JdbcOperation> extends AbstractSq
|
||||||
needle.accept( this );
|
needle.accept( this );
|
||||||
appendSql( ",'~','~~'),'?','~?'),'%','~%'),'%') escape '~'" );
|
appendSql( ",'~','~~'),'?','~?'),'%','~%'),'%') escape '~'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,7 @@ public class MySQLDialect extends Dialect {
|
||||||
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 8 );
|
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 8 );
|
||||||
|
|
||||||
private final MySQLStorageEngine storageEngine = createStorageEngine();
|
private final MySQLStorageEngine storageEngine = createStorageEngine();
|
||||||
|
|
||||||
private final SizeStrategy sizeStrategy = new SizeStrategyImpl() {
|
private final SizeStrategy sizeStrategy = new SizeStrategyImpl() {
|
||||||
@Override
|
@Override
|
||||||
public Size resolveSize(
|
public Size resolveSize(
|
||||||
|
|
|
@ -57,6 +57,10 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
|
||||||
return getSqlType( castTarget, sqlType, factory.getJdbcServices().getDialect() );
|
return getSqlType( castTarget, sqlType, factory.getJdbcServices().getDialect() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: this is really, really bad since it circumvents the whole machinery we have in DdlType
|
||||||
|
// and in the Dialect for doing this in a unified way! These mappings should be held in
|
||||||
|
// the DdlTypes themselves and should be set up in registerColumnTypes(). Doing it here
|
||||||
|
// means we have problems distinguishing, say, the 'as Character' special case
|
||||||
private static String getSqlType(CastTarget castTarget, String sqlType, Dialect dialect) {
|
private static String getSqlType(CastTarget castTarget, String sqlType, Dialect dialect) {
|
||||||
if ( sqlType != null ) {
|
if ( sqlType != null ) {
|
||||||
int parenthesesIndex = sqlType.indexOf( '(' );
|
int parenthesesIndex = sqlType.indexOf( '(' );
|
||||||
|
@ -72,9 +76,9 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
|
||||||
case "float":
|
case "float":
|
||||||
case "real":
|
case "real":
|
||||||
case "double precision":
|
case "double precision":
|
||||||
final int precision = castTarget.getPrecision() == null ?
|
final int precision = castTarget.getPrecision() == null
|
||||||
dialect.getDefaultDecimalPrecision() :
|
? dialect.getDefaultDecimalPrecision()
|
||||||
castTarget.getPrecision();
|
: castTarget.getPrecision();
|
||||||
final int scale = castTarget.getScale() == null ? Size.DEFAULT_SCALE : castTarget.getScale();
|
final int scale = castTarget.getScale() == null ? Size.DEFAULT_SCALE : castTarget.getScale();
|
||||||
return "decimal(" + precision + "," + scale + ")";
|
return "decimal(" + precision + "," + scale + ")";
|
||||||
case "char":
|
case "char":
|
||||||
|
@ -82,6 +86,7 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
|
||||||
case "nchar":
|
case "nchar":
|
||||||
case "nvarchar":
|
case "nvarchar":
|
||||||
if ( castTarget.getLength() == null ) {
|
if ( castTarget.getLength() == null ) {
|
||||||
|
// TODO: this is ugly and fragile, but could easily be handled in a DdlType
|
||||||
if ( castTarget.getJdbcMapping().getJdbcJavaType().getJavaType() == Character.class ) {
|
if ( castTarget.getJdbcMapping().getJdbcJavaType().getJavaType() == Character.class ) {
|
||||||
return "char(1)";
|
return "char(1)";
|
||||||
}
|
}
|
||||||
|
@ -94,7 +99,7 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
|
||||||
case "varbinary":
|
case "varbinary":
|
||||||
return castTarget.getLength() == null
|
return castTarget.getLength() == null
|
||||||
? "binary"
|
? "binary"
|
||||||
: ( "binary(" + castTarget.getLength() + ")" );
|
: "binary(" + castTarget.getLength() + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlType;
|
return sqlType;
|
||||||
|
|
|
@ -5746,11 +5746,11 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
renderCasted( expression );
|
renderCasted( expression );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( expression instanceof CaseSimpleExpression ) {
|
else if ( expression instanceof CaseSimpleExpression caseSimpleExpression ) {
|
||||||
visitCaseSimpleExpression( (CaseSimpleExpression) expression, true );
|
visitCaseSimpleExpression( caseSimpleExpression, true );
|
||||||
}
|
}
|
||||||
else if ( expression instanceof CaseSearchedExpression ) {
|
else if ( expression instanceof CaseSearchedExpression caseSearchedExpression ) {
|
||||||
visitCaseSearchedExpression( (CaseSearchedExpression) expression, true );
|
visitCaseSearchedExpression( caseSearchedExpression, true );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
renderExpressionAsClauseItem( expression );
|
renderExpressionAsClauseItem( expression );
|
||||||
|
@ -5758,8 +5758,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderCasted(Expression expression) {
|
protected void renderCasted(Expression expression) {
|
||||||
if ( expression instanceof SqmParameterInterpretation ) {
|
if ( expression instanceof SqmParameterInterpretation parameterInterpretation ) {
|
||||||
expression = ( (SqmParameterInterpretation) expression ).getResolvedExpression();
|
expression = parameterInterpretation.getResolvedExpression();
|
||||||
}
|
}
|
||||||
final List<SqlAstNode> arguments = new ArrayList<>( 2 );
|
final List<SqlAstNode> arguments = new ArrayList<>( 2 );
|
||||||
arguments.add( expression );
|
arguments.add( expression );
|
||||||
|
@ -5935,8 +5935,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
processNestedTableGroupJoins( tableGroup, null );
|
processNestedTableGroupJoins( tableGroup, null );
|
||||||
processTableGroupJoins( tableGroup );
|
processTableGroupJoins( tableGroup );
|
||||||
ModelPartContainer modelPart = tableGroup.getModelPart();
|
ModelPartContainer modelPart = tableGroup.getModelPart();
|
||||||
if ( modelPart instanceof EntityPersister ) {
|
if ( modelPart instanceof EntityPersister persister ) {
|
||||||
String[] querySpaces = (String[]) ( (EntityPersister) modelPart ).getQuerySpaces();
|
final String[] querySpaces = (String[]) persister.getQuerySpaces();
|
||||||
for ( int i = 0; i < querySpaces.length; i++ ) {
|
for ( int i = 0; i < querySpaces.length; i++ ) {
|
||||||
registerAffectedTable( querySpaces[i] );
|
registerAffectedTable( querySpaces[i] );
|
||||||
}
|
}
|
||||||
|
@ -6113,7 +6113,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
|
|
||||||
ModelPartContainer modelPart = tableGroup.getModelPart();
|
ModelPartContainer modelPart = tableGroup.getModelPart();
|
||||||
if ( modelPart instanceof EntityPersister persister ) {
|
if ( modelPart instanceof EntityPersister persister ) {
|
||||||
String[] querySpaces = (String[]) persister.getQuerySpaces();
|
final String[] querySpaces = (String[]) persister.getQuerySpaces();
|
||||||
for ( int i = 0; i < querySpaces.length; i++ ) {
|
for ( int i = 0; i < querySpaces.length; i++ ) {
|
||||||
registerAffectedTable( querySpaces[i] );
|
registerAffectedTable( querySpaces[i] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue