HHH-16260 - JdbcParameterRenderer not called with dynamic filters
HHH-16256 - JdbcParameterRenderer to have an impact on write operations HHH-16273 - Support for Dialect native JdbcParameterRenderer agroal tests :(
This commit is contained in:
parent
cb146ce397
commit
274af05b8a
|
@ -11,6 +11,9 @@ hibernate.connection.username @jdbc.user@
|
|||
hibernate.connection.password @jdbc.pass@
|
||||
hibernate.connection.init_sql @connection.init_sql@
|
||||
|
||||
# some Agroal tests fail with native markers. not sure why yet
|
||||
hibernate.dialect.native_param_markers=false
|
||||
|
||||
hibernate.jdbc.batch_size 10
|
||||
hibernate.connection.provider_class AgroalConnectionProvider
|
||||
|
||||
|
|
|
@ -1021,7 +1021,7 @@ public abstract class AbstractCollectionPersister
|
|||
String selectValue = isIntegerIndexed ?
|
||||
"max(" + getIndexColumnNames()[0] + ") + 1" : // lists, arrays
|
||||
"count(" + getElementColumnNames()[0] + ")"; // sets, maps, bags
|
||||
return new SimpleSelect( dialect )
|
||||
return new SimpleSelect( getFactory() )
|
||||
.setTableName( getTableName() )
|
||||
.addCondition( getKeyColumnNames(), "=?" )
|
||||
.addWhereToken( sqlWhereString )
|
||||
|
@ -1033,7 +1033,7 @@ public abstract class AbstractCollectionPersister
|
|||
if ( !hasIndex() ) {
|
||||
return null;
|
||||
}
|
||||
return new SimpleSelect( dialect )
|
||||
return new SimpleSelect( getFactory() )
|
||||
.setTableName( getTableName() )
|
||||
.addCondition( getKeyColumnNames(), "=?" )
|
||||
.addCondition( getIndexColumnNames(), "=?" )
|
||||
|
@ -1045,7 +1045,7 @@ public abstract class AbstractCollectionPersister
|
|||
|
||||
|
||||
protected String generateDetectRowByElementString() {
|
||||
return new SimpleSelect( dialect )
|
||||
return new SimpleSelect( getFactory() )
|
||||
.setTableName( getTableName() )
|
||||
.addCondition( getKeyColumnNames(), "=?" )
|
||||
.addCondition( getElementColumnNames(), "=?" )
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.hibernate.Internal;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.sql.ast.spi.JdbcParameterRenderer;
|
||||
|
||||
/**
|
||||
* A SQL {@code SELECT} statement with no table joins.
|
||||
|
@ -26,13 +28,6 @@ import org.hibernate.dialect.Dialect;
|
|||
*/
|
||||
@Internal
|
||||
public class SimpleSelect {
|
||||
|
||||
public SimpleSelect(Dialect dialect) {
|
||||
this.dialect = dialect;
|
||||
}
|
||||
|
||||
//private static final Alias DEFAULT_ALIAS = new Alias(10, null);
|
||||
|
||||
protected String tableName;
|
||||
protected String orderBy;
|
||||
protected String comment;
|
||||
|
@ -43,7 +38,16 @@ public class SimpleSelect {
|
|||
|
||||
protected LockOptions lockOptions = new LockOptions( LockMode.READ );
|
||||
|
||||
private final SessionFactoryImplementor factory;
|
||||
private final Dialect dialect;
|
||||
private JdbcParameterRenderer _jdbcParameterRenderer;
|
||||
|
||||
public SimpleSelect(SessionFactoryImplementor factory) {
|
||||
this.factory = factory;
|
||||
this.dialect = factory.getJdbcServices().getDialect();
|
||||
}
|
||||
|
||||
//private static final Alias DEFAULT_ALIAS = new Alias(10, null);
|
||||
|
||||
|
||||
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) {
|
||||
|
@ -100,22 +104,30 @@ public class SimpleSelect {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a complete {@linkplain org.hibernate.annotations.Where where} fragment. The {@code token} is added as-is
|
||||
*/
|
||||
public SimpleSelect addWhereToken(String token) {
|
||||
if (token != null ) {
|
||||
if (!whereTokens.isEmpty()) {
|
||||
and();
|
||||
}
|
||||
whereTokens.add( token );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private void and() {
|
||||
if ( whereTokens.size() > 0 ) {
|
||||
if ( !whereTokens.isEmpty() ) {
|
||||
whereTokens.add( "and" );
|
||||
}
|
||||
}
|
||||
|
||||
private JdbcParameterRenderer jdbcParameterRenderer() {
|
||||
if ( _jdbcParameterRenderer == null ) {
|
||||
_jdbcParameterRenderer = factory.getServiceRegistry().getService( JdbcParameterRenderer.class );
|
||||
}
|
||||
return _jdbcParameterRenderer;
|
||||
}
|
||||
|
||||
public SimpleSelect addCondition(String lhs, String op, String rhs) {
|
||||
and();
|
||||
whereTokens.add( lhs + ' ' + op + ' ' + rhs );
|
||||
|
@ -128,13 +140,6 @@ public class SimpleSelect {
|
|||
return this;
|
||||
}
|
||||
|
||||
public SimpleSelect addCondition(String[] lhs, String op, String[] rhs) {
|
||||
for ( int i = 0; i < lhs.length; i++ ) {
|
||||
addCondition( lhs[i], op, rhs[i] );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SimpleSelect addCondition(String[] lhs, String condition) {
|
||||
for ( String lh : lhs ) {
|
||||
if ( lh != null ) {
|
||||
|
|
Loading…
Reference in New Issue