Get rid of capturing lambdas for Bindable#JdbcValueConsumer

This commit is contained in:
Christian Beikov 2023-02-10 11:49:36 +01:00
parent 973434c8f1
commit 241cdf16d9
44 changed files with 401 additions and 184 deletions

View File

@ -187,10 +187,12 @@ public abstract class AbstractCompositeIdentifierMapping
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
int span = 0;
final EmbeddableMappingType embeddableTypeDescriptor = getEmbeddableTypeDescriptor();
@ -209,12 +211,14 @@ public abstract class AbstractCompositeIdentifierMapping
span += fkDescriptor.forEachJdbcValue(
identifier,
span + offset,
x,
y,
valuesConsumer,
session
);
}
else {
span += attributeMapping.forEachJdbcValue( o, span + offset, valuesConsumer, session );
span += attributeMapping.forEachJdbcValue( o, span + offset, x, y, valuesConsumer, session );
}
}
return span;

View File

@ -111,51 +111,131 @@ public interface Bindable extends JdbcMappingContainer {
* consumer.consume( 28 );
* ````
*
* Think of it as breaking the multi-dimensional array into a visitable flat array
* Think of it as breaking the multi-dimensional array into a visitable flat array.
* Additionally, it passes through the values {@code X} and {@code Y} to the consumer.
*/
default <X, Y> int forEachDisassembledJdbcValue(
Object value,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return forEachDisassembledJdbcValue( value, 0, x, y, valuesConsumer, session );
}
/**
* Like {@link #forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor)},
* but additionally receives an offset by which the selectionIndex is incremented when calling {@link JdbcValuesBiConsumer#consume(int, Object, Object, Object, JdbcMapping)}.
*/
<X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session);
/**
* A short hand form of {@link #forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor)},
* that passes null for the two values {@code X} and {@code Y}.
*/
default int forEachDisassembledJdbcValue(
Object value,
JdbcValuesConsumer valuesConsumer,
SharedSessionContractImplementor session) {
return forEachDisassembledJdbcValue( value, 0, valuesConsumer, session );
return forEachDisassembledJdbcValue( value, null, null, valuesConsumer, session );
}
int forEachDisassembledJdbcValue(
/**
* A short hand form of {@link #forEachDisassembledJdbcValue(Object, int, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor)},
* that passes null for the two values {@code X} and {@code Y} .
*/
default int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
SharedSessionContractImplementor session);
SharedSessionContractImplementor session) {
return forEachDisassembledJdbcValue( value, offset, null, null, valuesConsumer, session );
}
/**
* Visit each constituent JDBC value extracted from the entity instance itself.
*
* Short-hand form of calling {@link #disassemble} and piping its result to
* {@link #forEachDisassembledJdbcValue}
* {@link #forEachDisassembledJdbcValue(Object, JdbcValuesConsumer, SharedSessionContractImplementor)}
*/
default <X, Y> int forEachJdbcValue(
Object value,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return forEachJdbcValue( value, 0, x, y, valuesConsumer, session );
}
/**
* Visit each constituent JDBC value extracted from the entity instance itself.
*
* Short-hand form of calling {@link #disassemble} and piping its result to
* {@link #forEachDisassembledJdbcValue(Object, int, JdbcValuesConsumer, SharedSessionContractImplementor)}
*/
default <X, Y> int forEachJdbcValue(
Object value,
int offset,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return forEachDisassembledJdbcValue( disassemble( value, session ), offset, x, y, valuesConsumer, session );
}
/**
* A short hand form of {@link #forEachJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor)},
* that passes null for the two values {@code X} and {@code Y}.
*/
default int forEachJdbcValue(
Object value,
JdbcValuesConsumer valuesConsumer,
SharedSessionContractImplementor session) {
return forEachJdbcValue( value, 0, valuesConsumer, session );
return forEachJdbcValue( value, null, null, valuesConsumer, session );
}
/**
* A short hand form of {@link #forEachJdbcValue(Object, int, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor)},
* that passes null for the two values {@code X} and {@code Y}.
*/
default int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
SharedSessionContractImplementor session) {
return forEachDisassembledJdbcValue( disassemble( value, session ), offset, valuesConsumer, session );
return forEachJdbcValue( value, offset, null, null, valuesConsumer, session );
}
/**
* Functional interface for consuming the JDBC values. Essentially a {@link java.util.function.BiConsumer}
* Functional interface for consuming the JDBC values.
*/
@FunctionalInterface
interface JdbcValuesConsumer {
interface JdbcValuesConsumer extends JdbcValuesBiConsumer<Object, Object> {
@Override
default void consume(int selectionIndex, Object o, Object o2, Object jdbcValue, JdbcMapping jdbcMapping) {
consume( selectionIndex, jdbcValue, jdbcMapping );
}
/**
* Consume a JDBC-level jdbcValue. The JDBC jdbcMapping descriptor is also passed in
*/
void consume(int selectionIndex, Object jdbcValue, JdbcMapping jdbcMapping);
}
/**
* Functional interface for consuming the JDBC values, along with two values of type {@code X} and {@code Y}.
*/
@FunctionalInterface
interface JdbcValuesBiConsumer<X, Y> {
/**
* Consume a JDBC-level jdbcValue. The JDBC jdbcMapping descriptor is also passed in
*/
void consume(int selectionIndex, X x, Y y, Object jdbcValue, JdbcMapping jdbcMapping);
}
}

View File

@ -72,12 +72,14 @@ public interface EmbeddableValuedModelPart extends ValuedModelPart, Fetchable, F
}
@Override
default int forEachJdbcValue(
default <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return getEmbeddableTypeDescriptor().forEachJdbcValue( value, offset, valuesConsumer, session );
return getEmbeddableTypeDescriptor().forEachJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
@ -91,14 +93,18 @@ public interface EmbeddableValuedModelPart extends ValuedModelPart, Fetchable, F
}
@Override
default int forEachDisassembledJdbcValue(
default <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return getEmbeddableTypeDescriptor().forEachDisassembledJdbcValue(
value,
offset,
x,
y,
valuesConsumer,
session
);

View File

@ -101,20 +101,24 @@ public interface EntityValuedModelPart extends FetchableContainer {
}
@Override
default int forEachDisassembledJdbcValue(
default <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return getEntityMappingType().forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return getEntityMappingType().forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
default int forEachJdbcValue(
default <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
return getEntityMappingType().forEachJdbcValue( value, offset, consumer, session );
return getEntityMappingType().forEachJdbcValue( value, offset, x, y, consumer, session );
}
}

View File

@ -221,12 +221,14 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}

View File

@ -214,10 +214,12 @@ public class AnyDiscriminatorPart implements BasicValuedModelPart, FetchOptions,
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
throw new UnsupportedOperationException();
}

View File

@ -270,12 +270,14 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions {
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}
@ -303,12 +305,14 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return 1;
}

View File

@ -399,12 +399,14 @@ public class BasicAttributeMapping
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return getJdbcTypeCount();
}

View File

@ -376,12 +376,14 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return idType.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return idType.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -334,12 +334,14 @@ public class BasicValuedCollectionPart
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return getJdbcTypeCount();
}

View File

@ -317,11 +317,13 @@ public class CollectionIdentifierDescriptorImpl implements CollectionIdentifierD
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return type.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return type.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
}

View File

@ -386,10 +386,12 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
assert value instanceof Object[];
@ -398,16 +400,18 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
int span = 0;
for ( int i = 0; i < attributes.size(); i++ ) {
final SingularAttributeMapping attribute = attributes.get( i );
span += attribute.forEachDisassembledJdbcValue( incoming[ i ], span + offset, valuesConsumer, session );
span += attribute.forEachDisassembledJdbcValue( incoming[ i ], span + offset, x, y, valuesConsumer, session );
}
return span;
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
assert value instanceof Object[];
@ -417,7 +421,7 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement
int span = 0;
for ( int i = 0; i < attributes.size(); i++ ) {
final SingularAttributeMapping attribute = attributes.get( i );
span += attribute.forEachJdbcValue( incoming[ i ], span + offset, valuesConsumer, session );
span += attribute.forEachJdbcValue( incoming[ i ], span + offset, x, y, valuesConsumer, session );
}
return span;
}

View File

@ -266,21 +266,27 @@ public class DiscriminatedAssociationAttributeMapping
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
if ( value != null ) {
if ( value.getClass().isArray() ) {
final Object[] values = (Object[]) value;
valuesConsumer.consume(
offset,
x,
y,
values[0],
discriminatorMapping.getDiscriminatorPart().getJdbcMapping()
);
valuesConsumer.consume(
offset + 1,
x,
y,
values[1],
discriminatorMapping.getKeyPart().getJdbcMapping()
);
@ -294,6 +300,8 @@ public class DiscriminatedAssociationAttributeMapping
final Object disassembledDiscriminator = discriminatorMapping.getDiscriminatorPart().disassemble( discriminator, session );
valuesConsumer.consume(
offset,
x,
y,
disassembledDiscriminator,
discriminatorMapping.getDiscriminatorPart().getJdbcMapping()
);
@ -303,6 +311,8 @@ public class DiscriminatedAssociationAttributeMapping
final Object disassembledKey = discriminatorMapping.getKeyPart().disassemble( identifier, session );
valuesConsumer.consume(
offset + 1,
x,
y,
disassembledKey,
discriminatorMapping.getKeyPart().getJdbcMapping()
);

View File

@ -267,14 +267,18 @@ public class DiscriminatedCollectionPart implements DiscriminatedAssociationMode
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return discriminatorMapping.getDiscriminatorPart().forEachDisassembledJdbcValue(
value,
offset,
x,
y,
valuesConsumer,
session
);

View File

@ -760,10 +760,12 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
int span = 0;
@ -773,22 +775,24 @@ public class EmbeddableMappingTypeImpl extends AbstractEmbeddableMapping impleme
continue;
}
final Object o = attributeMapping.getPropertyAccess().getGetter().get( value );
span += attributeMapping.forEachJdbcValue( o, span + offset, consumer, session );
span += attributeMapping.forEachJdbcValue( o, span + offset, x, y, consumer, session );
}
return span;
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
for ( int i = 0; i < attributeMappings.size(); i++ ) {
final AttributeMapping mapping = attributeMappings.get( i );
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, valuesConsumer, session );
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, x, y, valuesConsumer, session );
}
return span;
}

View File

@ -586,12 +586,14 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return targetSide.getModelPart().forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return targetSide.getModelPart().forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -136,14 +136,18 @@ public class EmbeddedIdentifierMappingImpl
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return getEmbeddableTypeDescriptor().forEachDisassembledJdbcValue(
value,
offset,
x,
y,
valuesConsumer,
session
);

View File

@ -124,12 +124,14 @@ public class EntityRowIdMappingImpl implements EntityRowIdMapping {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return rowIdType.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return rowIdType.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -328,12 +328,14 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return versionBasicType.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return versionBasicType.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -405,10 +405,12 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
int span = 0;
@ -418,7 +420,7 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
continue;
}
final Object o = attributeMapping.getPropertyAccess().getGetter().get( value );
span += attributeMapping.forEachJdbcValue( o, span + offset, valuesConsumer, session );
span += attributeMapping.forEachJdbcValue( o, span + offset, x, y, valuesConsumer, session );
}
return span;
}
@ -437,10 +439,12 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
throw new UnsupportedOperationException();
}

View File

@ -134,12 +134,14 @@ public class InverseNonAggregatedIdentifierMapping extends EmbeddedAttributeMapp
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return identifierValueMapper.forEachJdbcValue( value, offset, valuesConsumer, session );
return identifierValueMapper.forEachJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -148,12 +148,12 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x, Y y, JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return identifierValueMapper.forEachJdbcValue( value, offset, valuesConsumer, session );
return identifierValueMapper.forEachJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -950,12 +950,14 @@ public class PluralAttributeMappingImpl
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return elementDescriptor.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return elementDescriptor.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -454,12 +454,14 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return 1;
}
@ -519,12 +521,14 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, disassemble( value, session ), targetSide.getModelPart().getJdbcMapping() );
valuesConsumer.consume( offset, x, y, disassemble( value, session ), targetSide.getModelPart().getJdbcMapping() );
return getJdbcTypeCount();
}

View File

@ -248,21 +248,25 @@ public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping implements
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return attribute.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return attribute.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return attribute.forEachJdbcValue( value, offset, valuesConsumer, session );
return attribute.forEachJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override

View File

@ -2148,19 +2148,23 @@ public class ToOneAttributeMapping
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return foreignKeyDescriptor.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return foreignKeyDescriptor.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
return foreignKeyDescriptor.forEachDisassembledJdbcValue(
foreignKeyDescriptor.disassemble(
@ -2168,6 +2172,8 @@ public class ToOneAttributeMapping
session
),
offset,
x,
y,
consumer,
session
);

View File

@ -298,10 +298,12 @@ public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements Id
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
int span = 0;
@ -311,7 +313,7 @@ public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements Id
continue;
}
final Object o = attributeMapping.getPropertyAccess().getGetter().get( value );
span += attributeMapping.forEachJdbcValue( o, span + offset, valuesConsumer, session );
span += attributeMapping.forEachJdbcValue( o, span + offset, x, y, valuesConsumer, session );
}
return span;
}
@ -356,16 +358,18 @@ public class VirtualIdEmbeddable extends AbstractEmbeddableMapping implements Id
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
for ( int i = 0; i < attributeMappings.size(); i++ ) {
final AttributeMapping mapping = attributeMappings.get( i );
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, valuesConsumer, session );
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, x, y, valuesConsumer, session );
}
return span;
}

View File

@ -94,10 +94,12 @@ public class ArrayTupleType implements TupleType<Object[]>,
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
throw new UnsupportedOperationException();
}

View File

@ -42,24 +42,28 @@ public class TupleMappingModelExpressible implements MappingModelExpressible {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
for ( int i = 0; i < components.length; i++ ) {
span += components[i].forEachDisassembledJdbcValue( values[i], span + offset, valuesConsumer, session );
span += components[i].forEachDisassembledJdbcValue( values[i], span + offset, x, y, valuesConsumer, session );
}
return span;
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
@ -67,7 +71,7 @@ public class TupleMappingModelExpressible implements MappingModelExpressible {
span += components[i].forEachDisassembledJdbcValue(
components[i].disassemble( values[i], session ),
span + offset,
valuesConsumer,
x, y, valuesConsumer,
session
);
}

View File

@ -5840,25 +5840,29 @@ public abstract class AbstractEntityPersister
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return getIdentifierMapping()
.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
final EntityIdentifierMapping identifierMapping = getIdentifierMapping();
final Object identifier = value == null ? null
: identifierMapping.disassemble( identifierMapping.getIdentifier( value ), session );
return identifierMapping.forEachDisassembledJdbcValue( identifier, offset, consumer, session );
return identifierMapping.forEachDisassembledJdbcValue( identifier, offset, x, y, consumer, session );
}
@Override

View File

@ -229,9 +229,11 @@ public class EntityTableMapping implements TableMapping {
SharedSessionContractImplementor session) {
identifierPart.forEachJdbcValue(
domainValue,
(selectionIndex, jdbcValue, jdbcMapping) -> valueConsumer.consume(
keyColumns,
valueConsumer,
(selectionIndex, keys, consumer, jdbcValue, jdbcMapping) -> consumer.consume(
jdbcValue,
keyColumns.get( selectionIndex )
keys.get( selectionIndex )
),
session
);

View File

@ -280,12 +280,14 @@ public class AnonymousTupleBasicValuedModelPart implements ModelPart, MappingTyp
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return getJdbcTypeCount();
}
@ -306,12 +308,14 @@ public class AnonymousTupleBasicValuedModelPart implements ModelPart, MappingTyp
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return getJdbcTypeCount();
}

View File

@ -431,33 +431,37 @@ public class AnonymousTupleEmbeddableValuedModelPart implements EmbeddableValued
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
int i = 0;
for ( ModelPart mapping : modelParts.values() ) {
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, valuesConsumer, session );
span += mapping.forEachDisassembledJdbcValue( values[i], span + offset, x, y, valuesConsumer, session );
i++;
}
return span;
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
final Object[] values = (Object[]) value;
int span = 0;
int i = 0;
for ( ModelPart attributeMapping : modelParts.values() ) {
final Object o = values[i];
span += attributeMapping.forEachJdbcValue( o, span + offset, consumer, session );
span += attributeMapping.forEachJdbcValue( o, span + offset, x, y, consumer, session );
i++;
}
return span;

View File

@ -563,21 +563,25 @@ public class AnonymousTupleEntityValuedModelPart
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return delegate.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return delegate.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer consumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> consumer,
SharedSessionContractImplementor session) {
return delegate.forEachJdbcValue( value, offset, consumer, session );
return delegate.forEachJdbcValue( value, offset, x, y, consumer, session );
}
@Override

View File

@ -42,8 +42,6 @@ import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.spi.FromClauseAccess;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.LazyTableGroup;
import org.hibernate.sql.ast.tree.from.PluralTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup;
@ -389,10 +387,12 @@ public class AnonymousTupleTableGroupProducer implements TableGroupProducer, Map
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
throw new UnsupportedOperationException( "Not yet implemented" );
}

View File

@ -272,7 +272,6 @@ import org.hibernate.query.sqm.tree.select.SqmSubQuery;
import org.hibernate.query.sqm.tree.update.SqmAssignment;
import org.hibernate.query.sqm.tree.update.SqmSetClause;
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
import org.hibernate.spi.EntityIdentifierNavigablePath;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstJoinType;
@ -5063,8 +5062,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
final List<Expression> list = new ArrayList<>( embeddableValuedModelPart.getJdbcTypeCount() );
embeddableValuedModelPart.forEachJdbcValue(
literal.getLiteralValue(),
(selectionIndex, value, jdbcMapping)
-> list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
list,
null,
(selectionIndex, expressions, noop, value, jdbcMapping)
-> expressions.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
null
);
return new SqlTuple( list, expressible );
@ -5107,8 +5108,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
final List<Expression> list = new ArrayList<>( associationKeyPart.getJdbcTypeCount() );
associationKeyPart.forEachJdbcValue(
associationKey,
(selectionIndex, value, jdbcMapping)
-> list.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
list,
null,
(selectionIndex, expressions, noop, value, jdbcMapping)
-> expressions.add( new QueryLiteral<>( value, (BasicValuedMapping) jdbcMapping ) ),
null
);
return new SqlTuple( list, associationKeyPart );

View File

@ -80,21 +80,25 @@ public class EntityTypeLiteral
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return discriminatorType.forEachDisassembledJdbcValue( value, offset, valuesConsumer, session );
return discriminatorType.forEachDisassembledJdbcValue( value, offset, x, y, valuesConsumer, session );
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return discriminatorType.forEachJdbcValue( value, offset, valuesConsumer, session );
return discriminatorType.forEachJdbcValue( value, offset, x, y, valuesConsumer, session );
}

View File

@ -119,22 +119,26 @@ public class JdbcLiteral<T> implements Literal, MappingModelExpressible<T>, Doma
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}

View File

@ -155,22 +155,26 @@ public abstract class AbstractJdbcParameter
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}
@Override
public int forEachJdbcValue(
public <X, Y> int forEachJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, jdbcMapping );
valuesConsumer.consume( offset, x, y, value, jdbcMapping );
return getJdbcTypeCount();
}
}

View File

@ -88,14 +88,16 @@ public interface JdbcParameterBindings {
return bindable.forEachJdbcValue(
value,
offset,
(selectionIndex, jdbcValue, type) -> {
jdbcParameters,
session.getFactory().getTypeConfiguration(),
(selectionIndex, params, typeConfiguration, jdbcValue, type) -> {
addBinding(
jdbcParameters.get( selectionIndex ),
params.get( selectionIndex ),
new JdbcParameterBindingImpl(
BindingTypeHelper.INSTANCE.resolveBindType(
jdbcValue,
type,
session.getFactory().getTypeConfiguration()
typeConfiguration
),
jdbcValue
)

View File

@ -123,12 +123,14 @@ public interface BasicType<T> extends Type, BasicDomainType<T>, MappingType, Bas
}
@Override
default int forEachDisassembledJdbcValue(
default <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
valuesConsumer.consume( offset, value, getJdbcMapping() );
valuesConsumer.consume( offset, x, y, value, getJdbcMapping() );
return getJdbcTypeCount();
}

View File

@ -193,10 +193,12 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return 0;
}

View File

@ -220,10 +220,12 @@ public class PersisterClassProviderTest {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return 0;
}

View File

@ -181,10 +181,12 @@ public class CustomPersister implements EntityPersister {
}
@Override
public int forEachDisassembledJdbcValue(
public <X, Y> int forEachDisassembledJdbcValue(
Object value,
int offset,
JdbcValuesConsumer valuesConsumer,
X x,
Y y,
JdbcValuesBiConsumer<X, Y> valuesConsumer,
SharedSessionContractImplementor session) {
return 0;
}