diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index eef8a9a59..0707451d6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -150,7 +150,7 @@ jobs:
# We want to enable preview features when testing newer builds of OpenJDK:
# even if we don't use these features, just enabling them can cause side effects
# and it's useful to test that.
- - { name: "20", java_version_numeric: 20, from: 'jdk.java.net', jvm_args: '--enable-preview' }
+ - { name: "20", java_version_numeric: 20, jvm_args: '--enable-preview' }
- { name: "21-ea", java_version_numeric: 21, from: 'jdk.java.net', jvm_args: '--enable-preview' }
- { name: "22-ea", java_version_numeric: 22, from: 'jdk.java.net', jvm_args: '--enable-preview' }
steps:
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/common/AffectedEntities.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/common/AffectedEntities.java
index 6a66a2c56..2f567787b 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/common/AffectedEntities.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/common/AffectedEntities.java
@@ -5,15 +5,17 @@
*/
package org.hibernate.reactive.common;
-import org.hibernate.Incubating;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.internal.util.collections.ArrayHelper;
-
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.hibernate.Incubating;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.internal.util.collections.ArrayHelper;
+
+import static java.util.Collections.addAll;
+
/**
* A description of the entities and tables affected by a native query.
*
@@ -25,7 +27,6 @@
*/
@Incubating
public class AffectedEntities {
- private static final Class>[] NO_ENTITIES = new Class[0];
private static final String[] NO_TABLES = new String[0];
private final String[] queryTables;
@@ -36,11 +37,6 @@ public AffectedEntities(Class>... queryEntities) {
this.queryEntities = queryEntities;
}
- public AffectedEntities(String... queryTables) {
- this.queryTables = queryTables;
- this.queryEntities = NO_ENTITIES;
- }
-
public String[] getAffectedTables() {
return queryTables;
}
@@ -51,11 +47,11 @@ public Class>[] getAffectedEntities() {
public String[] getAffectedSpaces(SessionFactoryImplementor factory) {
List spaces = new ArrayList<>();
- for ( String table : getAffectedTables() ) {
- spaces.add( table );
- }
+ addAll( spaces, getAffectedTables() );
for ( Class> entity : getAffectedEntities() ) {
- Serializable[] querySpaces = factory.getMetamodel().entityPersister( entity ).getQuerySpaces();
+ Serializable[] querySpaces = factory.getMappingMetamodel()
+ .getEntityDescriptor( entity.getName() )
+ .getQuerySpaces();
spaces.addAll( Arrays.asList( (String[]) querySpaces ) );
}
return spaces.toArray( ArrayHelper.EMPTY_STRING_ARRAY );
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java
index 608e627b8..144978be0 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java
@@ -1046,8 +1046,8 @@ public void sort(List insertions) {
actionDelegate.getEntityName(),
actionDelegate.getSession()
.getFactory()
- .getMetamodel()
- .entityPersister( actionDelegate.getEntityName() )
+ .getMappingMetamodel()
+ .getEntityDescriptor( actionDelegate.getEntityName() )
.getRootEntityName()
);
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/Cascade.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/Cascade.java
index b56382e50..1b63da2c3 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/Cascade.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/Cascade.java
@@ -26,6 +26,7 @@
import org.hibernate.engine.spi.Status;
import org.hibernate.event.spi.DeleteContext;
import org.hibernate.event.spi.EventSource;
+import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
@@ -314,7 +315,7 @@ private void cascadeLogicalOneToOneOrphanRemoval(
// Since the loadedState in the EntityEntry is a flat domain type array
// We first have to extract the component object and then ask the component type
// recursively to give us the value of the sub-property of that object
- final Type propertyType = entry.getPersister().getPropertyType( componentPath.get(0) );
+ final AttributeMapping propertyType = entry.getPersister().findAttributeMapping( componentPath.get( 0) );
if ( propertyType instanceof ComponentType) {
loadedValue = entry.getLoadedValue( componentPath.get( 0 ) );
ComponentType componentType = (ComponentType) propertyType;
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java
index a027c181b..879f7ddc8 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java
@@ -18,6 +18,7 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
@@ -394,8 +395,8 @@ else if ( isPersistentAttributeInterceptable( value ) ) {
// We now have the value of the property-ref we reference. However,
// we need to dig a little deeper, as that property might also be
// an entity type, in which case we need to resolve its identifier
- final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
- if ( type.isEntityType() ) {
+ final AttributeMapping type = entityPersister.findAttributeMapping( uniqueKeyPropertyName );
+ if ( type.isEntityIdentifierMapping() ) {
propertyValue = getIdentifier( (EntityType) type, propertyValue, session );
}
return completedFuture( propertyValue );
@@ -421,8 +422,8 @@ private static CompletionStage getIdentifierFromHibernateProxy(
// We now have the value of the property-ref we reference. However,
// we need to dig a little deeper, as that property might also be
// an entity type, in which case we need to resolve its identifier
- final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName );
- if ( type.isEntityType() ) {
+ final AttributeMapping type = entityPersister.findAttributeMapping( uniqueKeyPropertyName );
+ if ( type.isEntityIdentifierMapping() ) {
propertyValue = getIdentifier( (EntityType) type, propertyValue, (SessionImplementor) session );
}
return completedFuture( propertyValue );
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveFlushEntityEventListener.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveFlushEntityEventListener.java
index 0956e8e6a..1c7f58b05 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveFlushEntityEventListener.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveFlushEntityEventListener.java
@@ -158,7 +158,7 @@ public void onFlushEntity(FlushEntityEvent event) throws HibernateException {
// now update the object
// has to be outside the main if block above (because of collections)
if ( substitute ) {
- persister.setPropertyValues( entity, values );
+ persister.setValues( entity, values );
}
// Search for collections by reachability, updating their role.
@@ -266,7 +266,7 @@ private boolean scheduleUpdate(final FlushEntityEvent event) {
dirtyProperties,
event.hasDirtyCollection(),
status == Status.DELETED && !entry.isModifiableEntity()
- ? persister.getPropertyValues( entity )
+ ? persister.getValues( entity )
: entry.getLoadedState(),
entry.getVersion(),
nextVersion,
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveMergeEventListener.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveMergeEventListener.java
index 33dafbc2b..6a23b8d57 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveMergeEventListener.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveMergeEventListener.java
@@ -5,7 +5,6 @@
*/
package org.hibernate.reactive.event.impl;
-import java.io.Serializable;
import java.lang.invoke.MethodHandles;
import java.util.Map;
import java.util.concurrent.CompletionStage;
@@ -126,7 +125,7 @@ public CompletionStage reactiveOnMerge(MergeEvent event, MergeContext copi
if ( lazyInitializer != null ) {
if ( lazyInitializer.isUninitialized() ) {
LOG.trace( "Ignoring uninitialized proxy" );
- event.setResult( source.load( lazyInitializer.getEntityName(), lazyInitializer.getInternalIdentifier() ) );
+ event.setResult( source.getReference( lazyInitializer.getEntityName(), lazyInitializer.getInternalIdentifier() ) );
return voidFuture();
}
else {
@@ -140,7 +139,7 @@ else if ( isPersistentAttributeInterceptable( original ) ) {
final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) interceptor;
LOG.trace( "Ignoring uninitialized enhanced-proxy" );
//no need to go async, AFAICT ?
- event.setResult( source.load( proxyInterceptor.getEntityName(), (Serializable) proxyInterceptor.getIdentifier() ) );
+ event.setResult( source.getReference( proxyInterceptor.getEntityName(), proxyInterceptor.getIdentifier() ) );
//EARLY EXIT!
return voidFuture();
}
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java
index 077c62c97..cb71be1b8 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/DatabaseSnapshotExecutor.java
@@ -78,7 +78,7 @@ class DatabaseSnapshotExecutor {
LockOptions.NONE,
DatabaseSnapshotExecutor::visitEmptyFetchList,
true,
- LoadQueryInfluencers.NONE,
+ new LoadQueryInfluencers( sessionFactory ),
sessionFactory
);
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java
index 4d9c8dc70..56fef5be9 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveNaturalIdLoaderDelegate.java
@@ -237,7 +237,7 @@ public CompletionStage reactiveSelectByNaturalId(
lockOptions,
fetchProcessor,
true,
- LoadQueryInfluencers.NONE,
+ new LoadQueryInfluencers( sessionFactory ),
sessionFactory
);
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java
index efec8f373..9dd000a46 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleIdLoadPlan.java
@@ -17,7 +17,6 @@
import org.hibernate.loader.ast.internal.SingleIdLoadPlan;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ModelPart;
-import org.hibernate.persister.entity.Loadable;
import org.hibernate.query.internal.SimpleQueryOptions;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
@@ -36,13 +35,13 @@
public class ReactiveSingleIdLoadPlan extends SingleIdLoadPlan> {
public ReactiveSingleIdLoadPlan(
- EntityMappingType persister,
+ EntityMappingType entityMappingType,
ModelPart restrictivePart,
SelectStatement sqlAst,
JdbcParametersList jdbcParameters,
LockOptions lockOptions,
SessionFactoryImplementor sessionFactory) {
- super( persister, restrictivePart, sqlAst, jdbcParameters, lockOptions, sessionFactory );
+ super( entityMappingType, restrictivePart, sqlAst, jdbcParameters, lockOptions, sessionFactory );
}
@Override
@@ -77,7 +76,7 @@ public CompletionStage load(Object restrictedValue, Object entityInstance, Bo
private void invokeAfterLoadActions(Callback callback, SharedSessionContractImplementor session, T entity) {
if ( entity != null && getLoadable() != null) {
- callback.invokeAfterLoadActions( session, entity, (Loadable) getLoadable() );
+ callback.invokeAfterLoadActions( entity, (EntityMappingType) getLoadable(), session );
}
}
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java
index f8ba89540..62e5d0d44 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/loader/ast/internal/ReactiveSingleUniqueKeyEntityLoaderStandard.java
@@ -75,7 +75,7 @@ public CompletionStage load(Object ukValue, LockOptions lockOptions, Boolean
Collections.emptyList(),
uniqueKeyAttribute,
null,
- LoadQueryInfluencers.NONE,
+ new LoadQueryInfluencers( sessionFactory ),
LockOptions.NONE,
jdbcParametersListBuilder::add,
sessionFactory
@@ -131,7 +131,7 @@ public Object resolveId(Object ukValue, SharedSessionContractImplementor session
Collections.singletonList( entityDescriptor.getIdentifierMapping() ),
uniqueKeyAttribute,
null,
- LoadQueryInfluencers.NONE,
+ new LoadQueryInfluencers( sessionFactory ),
LockOptions.NONE,
jdbcParametersListBuilder::add,
sessionFactory
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java
index 461164b3c..09d421602 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java
@@ -36,8 +36,6 @@
import org.hibernate.metamodel.mapping.*;
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
import org.hibernate.persister.entity.AbstractEntityPersister;
-import org.hibernate.persister.entity.Lockable;
-import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.reactive.adaptor.impl.PreparedStatementAdaptor;
import org.hibernate.reactive.loader.ast.internal.ReactiveSingleIdArrayLoadPlan;
import org.hibernate.reactive.loader.ast.spi.ReactiveSingleIdEntityLoader;
@@ -85,7 +83,7 @@
* @see ReactiveUnionSubclassEntityPersister
* @see ReactiveSingleTableEntityPersister
*/
-public interface ReactiveAbstractEntityPersister extends ReactiveEntityPersister, OuterJoinLoadable, Lockable {
+public interface ReactiveAbstractEntityPersister extends ReactiveEntityPersister {
Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
@@ -117,11 +115,11 @@ default String generateSelectLockString(LockOptions lockOptions) {
final SessionFactoryImplementor factory = getFactory();
final SimpleSelect select = new SimpleSelect( factory )
.setLockOptions( lockOptions )
- .setTableName( getRootTableName() )
- .addColumn( getRootTableIdentifierColumnNames()[0] )
- .addRestriction( getRootTableIdentifierColumnNames() );
+ .setTableName( getEntityMappingType().getMappedTableDetails().getTableName() )
+ .addColumn( getIdentifierPropertyName() )
+ .addRestriction( getIdentifierPropertyName() );
if ( isVersioned() ) {
- select.addRestriction( getVersionColumnName() );
+ select.addRestriction( getVersionMapping().getVersionAttribute().getAttributeName() );
}
if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
select.setComment( lockOptions.getLockMode() + " lock " + getEntityName() );
@@ -132,10 +130,10 @@ default String generateSelectLockString(LockOptions lockOptions) {
default String generateUpdateLockString(LockOptions lockOptions) {
final SessionFactoryImplementor factory = getFactory();
final Update update = new Update( factory );
- update.setTableName( getRootTableName() );
- update.addAssignment( getVersionColumnName() );
- update.addRestriction( getRootTableIdentifierColumnNames() );
- update.addRestriction( getVersionColumnName() );
+ update.setTableName( getEntityMappingType().getMappedTableDetails().getTableName() );
+ update.addAssignment( getVersionMapping().getVersionAttribute().getAttributeName() );
+ update.addRestriction( getIdentifierPropertyName() );
+ update.addRestriction( getVersionMapping().getVersionAttribute().getAttributeName() );
if ( factory.getSessionFactoryOptions().isCommentsEnabled() ) {
update.setComment( lockOptions.getLockMode() + " lock " + getEntityName() );
}
@@ -261,8 +259,7 @@ default Object nextVersionForLock(LockMode lockMode, Object id, Object currentVe
@Override
default CompletionStage reactiveGetDatabaseSnapshot(Object id, SharedSessionContractImplementor session) {
- ReactiveSingleIdEntityLoader> reactiveSingleIdEntityLoader = getReactiveSingleIdEntityLoader();
- return reactiveSingleIdEntityLoader.reactiveLoadDatabaseSnapshot( id, session );
+ return getReactiveSingleIdEntityLoader().reactiveLoadDatabaseSnapshot( id, session );
}
default ReactiveSingleIdEntityLoader> getReactiveSingleIdEntityLoader() {
@@ -327,7 +324,7 @@ else if ( result instanceof PersistentCollection ) {
final String[] propertyNames = getPropertyNames();
for ( int index=0; index reactiveInitializeLazyPropertiesFromDatastore(
LOG.tracef( "Initializing lazy properties from datastore (triggered for `%s`)", fieldName );
- final String fetchGroup = getEntityMetamodel().getBytecodeEnhancementMetadata()
+ final String fetchGroup = getEntityPersister().getBytecodeEnhancementMetadata()
.getLazyAttributesMetadata()
.getFetchGroupName( fieldName );
- final List fetchGroupAttributeDescriptors = getEntityMetamodel().getBytecodeEnhancementMetadata()
+ final List fetchGroupAttributeDescriptors = getEntityPersister().getBytecodeEnhancementMetadata()
.getLazyAttributesMetadata()
.getFetchGroupAttributeDescriptors( fetchGroup );
@@ -455,7 +452,7 @@ default CompletionStage reactiveInitializeEnhancedEntityUsedAsProxy(
String nameOfAttributeBeingAccessed,
SharedSessionContractImplementor session) {
- final BytecodeEnhancementMetadata enhancementMetadata = getEntityMetamodel().getBytecodeEnhancementMetadata();
+ final BytecodeEnhancementMetadata enhancementMetadata = getEntityPersister().getBytecodeEnhancementMetadata();
final BytecodeLazyAttributeInterceptor currentInterceptor = enhancementMetadata.extractLazyInterceptor( entity );
if ( currentInterceptor instanceof EnhancementAsProxyLazinessInterceptor) {
final EnhancementAsProxyLazinessInterceptor proxyInterceptor =
@@ -540,11 +537,11 @@ default NaturalIdMapping generateNaturalIdMapping(
//noinspection AssertWithSideEffects
assert bootEntityDescriptor.hasNaturalId();
- final int[] naturalIdAttributeIndexes = getEntityMetamodel().getNaturalIdentifierProperties();
+ final int[] naturalIdAttributeIndexes = getEntityPersister().getNaturalIdentifierProperties();
assert naturalIdAttributeIndexes.length > 0;
if ( naturalIdAttributeIndexes.length == 1 ) {
- final String propertyName = getEntityMetamodel().getPropertyNames()[naturalIdAttributeIndexes[0]];
+ final String propertyName = getEntityPersister().getAttributeMappings().get(naturalIdAttributeIndexes[0]).getAttributeName();
final AttributeMapping attributeMapping = findAttributeMapping( propertyName );
final SingularAttributeMapping singularAttributeMapping = (SingularAttributeMapping) attributeMapping;
return new ReactiveSimpleNaturalIdMapping( singularAttributeMapping, this, creationProcess );
@@ -584,7 +581,7 @@ default NaturalIdLoader> getNaturalIdLoader() {
* @see AbstractEntityPersister#getLazyLoadPlanByFetchGroup()
*/
default Map getLazyLoadPlanByFetchGroup(String[] subclassPropertyNameClosure ) {
- final BytecodeEnhancementMetadata metadata = delegate().getEntityMetamodel().getBytecodeEnhancementMetadata();
+ final BytecodeEnhancementMetadata metadata = delegate().getEntityPersister().getBytecodeEnhancementMetadata();
return metadata.isEnhancedForLazyLoading() && metadata.getLazyAttributesMetadata().hasLazyAttributes()
? createLazyLoadPlanByFetchGroup( metadata, subclassPropertyNameClosure )
: emptyMap();
@@ -626,7 +623,7 @@ default ReactiveSingleIdArrayLoadPlan createLazyLoadPlan(List reactivePreInsertInMemoryValueGeneration(Object[]
stage = stage.thenCompose( v -> generateValue( session, entity, currentValue, beforeGenerator, INSERT )
.thenAccept( generatedValue -> {
currentValues[index] = generatedValue;
- entityPersister().setPropertyValue( entity, index, generatedValue );
+ entityPersister().setValue( entity, index, generatedValue );
} ) );
}
}
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveUpdateCoordinatorStandard.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveUpdateCoordinatorStandard.java
index 2b5425bb1..04b50217a 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveUpdateCoordinatorStandard.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveUpdateCoordinatorStandard.java
@@ -193,7 +193,7 @@ private CompletionStage reactivePreUpdateInMemoryValueGeneration(
result = result.thenCompose( v -> generateValue( session, entity, currentValue, beforeGenerator, INSERT )
.thenAccept( generatedValue -> {
currentValues[index] = generatedValue;
- entityPersister().setPropertyValue( entity, index, generatedValue );
+ entityPersister().setValue( entity, index, generatedValue );
fieldsPreUpdateNeeded[count.getAndIncrement()] = index;
} ) );
}
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/impl/ReactiveEntityManagerFactoryBuilder.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/impl/ReactiveEntityManagerFactoryBuilder.java
index 19cb42f71..9752df913 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/impl/ReactiveEntityManagerFactoryBuilder.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/impl/ReactiveEntityManagerFactoryBuilder.java
@@ -55,7 +55,13 @@ public EntityManagerFactory build() {
int batchSize = ConfigurationHelper.getInt( Settings.STATEMENT_BATCH_SIZE, getConfigurationValues(), 0 );
optionsBuilder.applyJdbcBatchSize(batchSize);
- final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( metadata, optionsBuilder );
+ final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl(
+ metadata,
+ optionsBuilder,
+ metadata.getTypeConfiguration()
+ .getMetadataBuildingContext()
+ .getBootstrapContext()
+ );
final SessionFactoryBuilderImplementor reactiveSessionFactoryBuilder = new ReactiveSessionFactoryBuilder( metadata, defaultBuilder );
populateSfBuilder( reactiveSessionFactoryBuilder, getStandardServiceRegistry() );
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java
index 04b83a155..fd7a45f9b 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java
@@ -1167,7 +1167,7 @@ public CompletionStage> reactiveFind(Class entityClass, Object...
@Override
public CompletionStage reactiveFind(Class entityClass, Map ids) {
- final EntityPersister persister = getFactory().getMetamodel().locateEntityPersister( entityClass );
+ final EntityPersister persister = getFactory().getMappingMetamodel().getEntityDescriptor( entityClass );
return new NaturalIdLoadAccessImpl( persister ).resolveNaturalId( ids )
.thenCompose( id -> reactiveFind( entityClass, id, null, null ) );
}
@@ -1232,11 +1232,11 @@ public ReactiveIdentifierLoadAccessImpl(EntityPersister entityPersister) {
}
public ReactiveIdentifierLoadAccessImpl(String entityName) {
- this( getFactory().getMetamodel().locateEntityPersister( entityName ) );
+ this( getFactory().getMappingMetamodel().getEntityDescriptor( entityName ) );
}
public ReactiveIdentifierLoadAccessImpl(Class entityClass) {
- this( getFactory().getMetamodel().locateEntityPersister( entityClass ) );
+ this( getFactory().getMappingMetamodel().getEntityDescriptor( entityClass ) );
}
public final ReactiveIdentifierLoadAccessImpl with(LockOptions lockOptions) {
@@ -1380,7 +1380,7 @@ public ReactiveMultiIdentifierLoadAccessImpl(EntityPersister entityPersister) {
}
public ReactiveMultiIdentifierLoadAccessImpl(Class entityClass) {
- this( getFactory().getMetamodel().locateEntityPersister( entityClass ) );
+ this( getFactory().getMappingMetamodel().getEntityDescriptor( entityClass ) );
}
@Override
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java
index 05532b4e1..6ae79f209 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java
@@ -76,7 +76,6 @@
import org.hibernate.reactive.query.sqm.internal.ReactiveSqmSelectionQueryImpl;
import org.hibernate.reactive.session.ReactiveSqmQueryImplementor;
import org.hibernate.reactive.session.ReactiveStatelessSession;
-import org.hibernate.tuple.entity.EntityMetamodel;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.Tuple;
@@ -509,8 +508,7 @@ public CompletionStage reactiveInternalLoad(
// first, check to see if we can use "bytecode proxies"
- final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
- final BytecodeEnhancementMetadata enhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
+ final BytecodeEnhancementMetadata enhancementMetadata = persister.getBytecodeEnhancementMetadata();
if ( enhancementMetadata.isEnhancedForLazyLoading() ) {
// if the entity defines a HibernateProxy factory, see if there is an
@@ -530,7 +528,7 @@ public CompletionStage reactiveInternalLoad(
}
// specialized handling for entities with subclasses with a HibernateProxy factory
- if ( entityMetamodel.hasSubclasses() ) {
+ if ( persister.hasSubclasses() ) {
// entities with subclasses that define a ProxyFactory can create
// a HibernateProxy.
// LOG.debugf( "Creating a HibernateProxy for to-one association with subclasses to honor laziness" );
@@ -538,7 +536,7 @@ public CompletionStage reactiveInternalLoad(
}
return completedFuture( enhancementMetadata.createEnhancedProxy( entityKey, false, this ) );
}
- else if ( !entityMetamodel.hasSubclasses() ) {
+ else if ( !persister.hasSubclasses() ) {
return completedFuture( enhancementMetadata.createEnhancedProxy( entityKey, false, this ) );
}
// If we get here, then the entity class has subclasses and there is no HibernateProxy factory.
diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/entity/ReactiveAbstractEntityInitializer.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/entity/ReactiveAbstractEntityInitializer.java
index 389cee1f3..5b2b86cd4 100644
--- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/entity/ReactiveAbstractEntityInitializer.java
+++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/entity/ReactiveAbstractEntityInitializer.java
@@ -219,7 +219,7 @@ private CompletionStage initializeEntityInstance(Object toInitialize, RowP
.injectInterceptor( toInitialize, entityIdentifier, session );
}
}
- getConcreteDescriptor().setPropertyValues( toInitialize, getResolvedEntityState() );
+ getConcreteDescriptor().setValues( toInitialize, getResolvedEntityState() );
persistenceContext.addEntity( getEntityKey(), toInitialize );
// Also register possible unique key entries
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchFetchTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchFetchTest.java
index 94e11d411..48032f684 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchFetchTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchFetchTest.java
@@ -54,8 +54,8 @@ protected Collection> annotatedEntities() {
@AfterEach
public void cleanDb(VertxTestContext context) {
test( context, getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from Element" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Node" ).executeUpdate() ) ) );
+ .withTransaction( s -> s.createMutationQuery( "delete from Element" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Node" ).executeUpdate() ) ) );
}
@Test
@@ -71,7 +71,7 @@ public void testQuery(VertxTestContext context) {
test( context, getSessionFactory()
.withTransaction( s -> s.persist( basik ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "from Node n order by id", Node.class )
+ .thenCompose( s -> s.createSelectionQuery( "from Node n order by id", Node.class )
.getResultList()
.thenCompose( list -> {
assertEquals( list.size(), 2 );
@@ -88,7 +88,7 @@ public void testQuery(VertxTestContext context) {
} )
)
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "from Element e order by id", Element.class )
+ .thenCompose( s -> s.createSelectionQuery( "from Element e order by id", Element.class )
.getResultList()
.thenCompose( list -> {
assertEquals( list.size(), 5 );
@@ -147,7 +147,7 @@ public void testWithCollection(VertxTestContext context) {
.withTransaction( s -> s.persist( node ) )
.thenCompose( v -> getSessionFactory()
.withTransaction( s -> s
- .createQuery( "from Node n order by id", Node.class )
+ .createSelectionQuery( "from Node n order by id", Node.class )
.getResultList()
.thenCompose( list -> {
assertEquals( list.size(), 1 );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java
index 9608bec81..675cbc4c3 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchQueryOnConnectionTest.java
@@ -119,8 +119,8 @@ public CompletionStage>> doBatchInserts(VertxTestContext con
return stage
.thenCompose( ignore -> openSession() )
.thenCompose( s -> s
- .createQuery( "select count(*) from DataPoint" ).getSingleResult()
- .thenAccept( result -> assertEquals( (long) nEntities, result ) ) )
+ .createSelectionQuery( "select count(*) from DataPoint", Long.class ).getSingleResult()
+ .thenAccept( result -> assertEquals( nEntities, result ) ) )
.thenApply( v -> paramsBatches );
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java
index d651c9074..cc44e8b24 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/BatchingConnectionTest.java
@@ -76,7 +76,7 @@ public void testBatchingWithPersistAll(VertxTestContext context) {
)
// Auto-flush
.thenCompose( v -> s
- .createQuery( "select name from GuineaPig" )
+ .createSelectionQuery( "select name from GuineaPig", String.class )
.getResultList()
.thenAccept( names -> {
assertThat( names ).containsExactlyInAnyOrder( "One", "Two", "Three" );
@@ -101,7 +101,7 @@ public void testBatching(VertxTestContext context) {
.thenCompose( v -> s.persist( new GuineaPig(22, "Two") ) )
.thenCompose( v -> s.persist( new GuineaPig(33, "Three") ) )
// Auto-flush
- .thenCompose( v -> s.createQuery("select name from GuineaPig")
+ .thenCompose( v -> s.createSelectionQuery("select name from GuineaPig", String.class )
.getResultList()
.thenAccept( names -> {
assertThat( names ).containsExactlyInAnyOrder( "One", "Two", "Three" );
@@ -114,10 +114,10 @@ public void testBatching(VertxTestContext context) {
)
)
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery("from GuineaPig")
+ .thenCompose( s -> s.createSelectionQuery("from GuineaPig", GuineaPig.class)
.getResultList()
.thenAccept( list -> list.forEach( pig -> pig.setName("Zero") ) )
- .thenCompose( v -> s.createQuery("select count(*) from GuineaPig where name='Zero'")
+ .thenCompose( v -> s.createSelectionQuery("select count(*) from GuineaPig where name='Zero'", Long.class)
.getSingleResult()
.thenAccept( count -> {
assertEquals( 3L, count);
@@ -130,10 +130,10 @@ public void testBatching(VertxTestContext context) {
} )
) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery("from GuineaPig")
+ .thenCompose( s -> s.createSelectionQuery("from GuineaPig", GuineaPig.class)
.getResultList()
.thenCompose( list -> loop( list, s::remove ) )
- .thenCompose( v -> s.createQuery("select count(*) from GuineaPig")
+ .thenCompose( v -> s.createSelectionQuery("select count(*) from GuineaPig", Long.class)
.getSingleResult()
.thenAccept( count -> {
assertEquals( 0L, count);
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CacheTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CacheTest.java
index 0e42c1180..f87d108a5 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CacheTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CacheTest.java
@@ -64,7 +64,7 @@ public void testCacheWithHQL(VertxTestContext context) {
} )
//populate the cache
.thenCompose( v -> getSessionFactory().withSession(
- s -> s.createQuery( "from Named" ).getResultList()
+ s -> s.createSelectionQuery( "from Named", Named.class ).getResultList()
.thenAccept( list -> assertEquals( 3, list.size() ) )
) )
.thenAccept( v -> {
@@ -83,7 +83,7 @@ public void testCacheWithHQL(VertxTestContext context) {
) )
//change the database
.thenCompose( v -> getSessionFactory().withSession(
- s -> s.createQuery( "update Named set name='x'||name" ).executeUpdate()
+ s -> s.createMutationQuery( "update Named set name='x'||name" ).executeUpdate()
) )
.thenAccept( v -> {
assertFalse( cache.contains( Named.class, 1 ) );
@@ -111,7 +111,7 @@ public void testCacheWithHQL(VertxTestContext context) {
} )
//repopulate the cache
.thenCompose( v -> getSessionFactory().withSession(
- s -> s.createQuery( "from Named" ).getResultList()
+ s -> s.createSelectionQuery( "from Named", Named.class ).getResultList()
.thenAccept( list -> assertEquals( 3, list.size() ) )
) )
.thenAccept( v -> {
@@ -125,7 +125,7 @@ public void testCacheWithHQL(VertxTestContext context) {
) )
//change the database
.thenCompose( v -> getSessionFactory().withSession(
- s -> s.createQuery( "delete Named" ).executeUpdate()
+ s -> s.createMutationQuery( "delete Named" ).executeUpdate()
) )
.thenAccept( v -> {
assertFalse( cache.contains( Named.class, 1 ) );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CachedQueryResultsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CachedQueryResultsTest.java
index 260d6297b..e58b4db23 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CachedQueryResultsTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CachedQueryResultsTest.java
@@ -139,7 +139,7 @@ public static CriteriaQuery criteriaQuery(CriteriaBuilder criteriaBuilder
}
private static Uni> findAllWithCacheableQuery(Mutiny.Session session) {
- return session.createQuery( "FROM Fruit f ORDER BY f.name ASC", Fruit.class )
+ return session.createSelectionQuery( "FROM Fruit f ORDER BY f.name ASC", Fruit.class )
.setCacheable( true )
.getResultList();
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdManyToOneTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdManyToOneTest.java
index 9e482a977..b23f417b2 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdManyToOneTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdManyToOneTest.java
@@ -54,7 +54,7 @@ public void reactivePersist(VertxTestContext context) {
.thenCompose( s -> s.persist( gl )
.thenCompose( v -> s.flush() )
).thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery("from ShoppingItem si where si.groceryList.id = :gl")
+ .thenCompose( s -> s.createSelectionQuery("from ShoppingItem si where si.groceryList.id = :gl", ShoppingItem.class)
.setParameter("gl", gl.id)
.getResultList() )
.thenAccept( list -> assertEquals( 1, list.size() ) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdTest.java
index edecd7f0b..1e00b1b0f 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/CompositeIdTest.java
@@ -50,17 +50,17 @@ private CompletionStage selectNameFromId(Integer id) {
}
private CompletionStage selectNameFromId(Stage.Session session, Integer id) {
- return session.createQuery( "SELECT name FROM GuineaPig WHERE id = " + id )
+ return session.createSelectionQuery( "SELECT name FROM GuineaPig WHERE id = " + id, String.class )
.getResultList()
.thenApply( CompositeIdTest::nameFromResult );
}
- private static String nameFromResult(List rowSet) {
+ private static String nameFromResult(List rowSet) {
switch ( rowSet.size() ) {
case 0:
return null;
case 1:
- return (String) rowSet.get( 0 );
+ return rowSet.get( 0 );
default:
throw new AssertionError( "More than one result returned: " + rowSet.size() );
}
@@ -68,18 +68,18 @@ private static String nameFromResult(List rowSet) {
private CompletionStage selectWeightFromId(Integer id) {
return getSessionFactory().withSession(
- session -> session.createQuery("SELECT weight FROM GuineaPig WHERE id = " + id )
+ session -> session.createSelectionQuery("SELECT weight FROM GuineaPig WHERE id = " + id, Double.class )
.getResultList()
.thenApply( CompositeIdTest::weightFromResult )
);
}
- private static Double weightFromResult(List rowSet) {
+ private static Double weightFromResult(List rowSet) {
switch ( rowSet.size() ) {
case 0:
return null;
case 1:
- return (Double) rowSet.get(0);
+ return rowSet.get(0);
default:
throw new AssertionError("More than one result returned: " + rowSet.size());
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EagerTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EagerTest.java
index 42b6f1324..9195d93a7 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EagerTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EagerTest.java
@@ -63,8 +63,8 @@ protected Configuration constructConfiguration() {
@Override
protected CompletionStage cleanDb() {
return getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from Element" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Node" ).executeUpdate() )
+ .withTransaction( s -> s.createMutationQuery( "delete from Element" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Node" ).executeUpdate() )
.thenCompose( CompletionStages::voidFuture ) );
}
@@ -127,7 +127,7 @@ public void testEagerParentFetchQuery(VertxTestContext context) {
openSession()
.thenCompose(s -> s.persist(basik).thenCompose(v -> s.flush()))
.thenCompose( v -> openSession() )
- .thenCompose(s -> s.createQuery( "from Element", Element.class ).getResultList())
+ .thenCompose(s -> s.createSelectionQuery( "from Element", Element.class ).getResultList())
.thenAccept( elements -> {
for (Element element: elements) {
assertTrue( Hibernate.isInitialized( element.getNode() ) );
@@ -151,7 +151,7 @@ public void testEagerFetchQuery(VertxTestContext context) {
openSession()
.thenCompose(s -> s.persist(basik).thenCompose(v -> s.flush()))
.thenCompose( v -> openSession() )
- .thenCompose(s -> s.createQuery("from Node order by id", Node.class).getResultList())
+ .thenCompose(s -> s.createSelectionQuery("from Node order by id", Node.class).getResultList())
.thenAccept(list -> {
assertEquals(list.size(), 2);
assertTrue( Hibernate.isInitialized( list.get(0).getElements() ) );
@@ -159,10 +159,10 @@ public void testEagerFetchQuery(VertxTestContext context) {
assertEquals(list.get(1).getElements().size(), 0);
})
.thenCompose( v -> openSession() )
- .thenCompose(s -> s.createQuery("select distinct n, e from Node n join n.elements e order by n.id").getResultList())
+ .thenCompose(s -> s.createSelectionQuery("select distinct n, e from Node n join n.elements e order by n.id", Object[].class).getResultList())
.thenAccept(list -> {
assertEquals(list.size(), 3);
- Object[] tup = (Object[]) list.get(0);
+ Object[] tup = list.get(0);
assertTrue( Hibernate.isInitialized( ((Node) tup[0]).getElements() ) );
assertEquals(((Node) tup[0]).getElements().size(), 3);
})
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchModeSubselectEagerTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchModeSubselectEagerTest.java
index 18a040d6a..388baec9a 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchModeSubselectEagerTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchModeSubselectEagerTest.java
@@ -63,8 +63,8 @@ protected Configuration constructConfiguration() {
@Override
protected CompletionStage cleanDb() {
return getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from Element" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Node" ).executeUpdate() )
+ .withTransaction( s -> s.createMutationQuery( "delete from Element" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Node" ).executeUpdate() )
.thenCompose( CompletionStages::voidFuture ) );
}
@@ -130,7 +130,7 @@ public void testEagerFetchQuery(VertxTestContext context) {
openSession()
.thenCompose( s -> s.persist( basik ).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "from Node order by id", Node.class ).getResultList() )
+ .thenCompose( s -> s.createSelectionQuery( "from Node order by id", Node.class ).getResultList() )
.thenAccept( list -> {
assertEquals( list.size(), 2 );
assertTrue( Hibernate.isInitialized( list.get( 0 ).elements ) );
@@ -138,11 +138,11 @@ public void testEagerFetchQuery(VertxTestContext context) {
assertEquals( list.get( 1 ).elements.size(), 0 );
} )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery(
- "select distinct n, e from Node n join n.elements e order by n.id" ).getResultList() )
+ .thenCompose( s -> s.createSelectionQuery(
+ "select distinct n, e from Node n join n.elements e order by n.id", Object[].class ).getResultList() )
.thenAccept( list -> {
assertEquals( list.size(), 3 );
- Object[] tup = (Object[]) list.get( 0 );
+ Object[] tup = list.get( 0 );
assertTrue( Hibernate.isInitialized( ( (Node) tup[0] ).elements ) );
assertEquals( ( (Node) tup[0] ).elements.size(), 3 );
} )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java
index ac72c9efe..87e264ff5 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FetchedAssociationTest.java
@@ -78,7 +78,7 @@ public void testWithMutiny(VertxTestContext context) {
} )
.call( () -> getMutinySessionFactory()
.withTransaction( s -> s
- .createQuery( "From Parent", Parent.class )
+ .createSelectionQuery( "From Parent", Parent.class )
.getSingleResult()
.call( parent -> {
Child child = new Child();
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterTest.java
index a9911763d..1ed173916 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/FilterTest.java
@@ -38,6 +38,7 @@
import jakarta.persistence.Version;
import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Timeout(value = 10, timeUnit = MINUTES)
@@ -59,8 +60,8 @@ protected Configuration constructConfiguration() {
@Override
protected CompletionStage cleanDb() {
return getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from Element" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Node" ).executeUpdate() )
+ .withTransaction( s -> s.createMutationQuery( "delete from Element" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Node" ).executeUpdate() )
.thenCompose( CompletionStages::voidFuture ) );
}
@@ -80,18 +81,18 @@ public void testFilter(VertxTestContext context) {
.thenCompose( v -> openSession()
.thenCompose( s -> {
s.enableFilter( "current" );
- return s.createQuery( "select distinct n from Node n left join fetch n.elements order by n.id" )
+ return s.createSelectionQuery( "select distinct n from Node n left join fetch n.elements order by n.id", Node.class )
.setComment( "Hello World!" )
.getResultList();
} ) )
.thenAccept( list -> {
assertEquals( list.size(), 2 );
- assertEquals( ( (Node) list.get( 0 ) ).elements.size(), 2 );
+ assertEquals( list.get( 0 ).elements.size(), 2 );
} )
.thenCompose( v -> openSession()
.thenCompose( s -> {
s.enableFilter( "current" );
- return s.createQuery( "select distinct n, e from Node n join n.elements e" )
+ return s.createSelectionQuery( "select distinct n, e from Node n join n.elements e", Object[].class )
.getResultList();
} ) )
.thenAccept( list -> assertEquals( list.size(), 2 ) )
@@ -119,22 +120,22 @@ public void testFilterWithParameter(VertxTestContext context) {
.thenCompose( v -> openSession()
.thenCompose( s -> {
s.enableFilter( "region" ).setParameter( "region", "oceania" );
- return s.createQuery(
- "select distinct n from Node n left join fetch n.elements order by n.id" )
+ return s.createSelectionQuery(
+ "select distinct n from Node n left join fetch n.elements order by n.id", Node.class )
.setComment( "Hello World!" )
.getResultList();
} ) )
.thenAccept( list -> {
- assertEquals( list.size(), 2 );
- assertEquals( ( (Node) list.get( 0 ) ).elements.size(), 2 );
+ assertThat( list ).hasSize( 2 );
+ assertThat( list.get( 0 ).elements ).hasSize( 2 );
} )
.thenCompose( v -> openSession()
.thenCompose( s -> {
s.enableFilter( "region" ).setParameter( "region", "oceania" );
- return s.createQuery( "select distinct n, e from Node n join n.elements e" )
+ return s.createSelectionQuery( "select distinct n, e from Node n join n.elements e", Object[].class )
.getResultList();
} ) )
- .thenAccept( list -> assertEquals( list.size(), 2 ) )
+ .thenAccept( list -> assertThat( list ).hasSize( 2 ) )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java
index b53398dd5..7e4871ece 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedLimitTest.java
@@ -59,7 +59,7 @@ public void populateDb(VertxTestContext context) {
public void testNoResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where id = :id" )
+ .createSelectionQuery( "from Flour where id = :id", Flour.class )
.setMaxResults( 0 )
.setParameter( "id", rye.getId() )
.getResultList()
@@ -72,7 +72,7 @@ public void testNoResults(VertxTestContext context) {
public void testFirstResultNoResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour" )
+ .createSelectionQuery( "from Flour", Flour.class )
.setMaxResults( 0 )
.setFirstResult( 1 )
.getResultList()
@@ -87,7 +87,7 @@ public void testFirstResultNoResults(VertxTestContext context) {
@Test
public void testFirstResultWithoutOrderBy(VertxTestContext context) {
test( context, openSession()
- .thenCompose( s -> s.createQuery( "from Flour where id > :id" )
+ .thenCompose( s -> s.createSelectionQuery( "from Flour where id > :id", Flour.class )
.setParameter( "id", 1 )
.setMaxResults( 1 )
.setFirstResult( 1 )
@@ -101,7 +101,7 @@ public void testFirstResultWithoutOrderBy(VertxTestContext context) {
public void testFirstResultSingleResult(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name != :name order by id" )
+ .createSelectionQuery( "from Flour where name != :name order by id", Flour.class )
.setParameter( "name", spelt.getName() )
.setFirstResult( 1 )
.getSingleResult()
@@ -114,7 +114,7 @@ public void testFirstResultSingleResult(VertxTestContext context) {
public void testFirstResultMultipleResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.getResultList()
.thenAccept( results -> {
@@ -130,7 +130,7 @@ public void testFirstResultMultipleResults(VertxTestContext context) {
public void testFirstResultMaxResultsSingleResult(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 1 )
.getSingleResult()
@@ -146,7 +146,7 @@ public void testFirstResultMaxResultsSingleResult(VertxTestContext context) {
public void testFirstResultZeroAndMaxResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name = :name order by id" )
+ .createSelectionQuery( "from Flour where name = :name order by id", Flour.class )
.setParameter( "name", almond.getName() )
.setFirstResult( 0 )
.setMaxResults( 10 )
@@ -167,7 +167,7 @@ public void testFirstResultZeroAndMaxResults(VertxTestContext context) {
public void testFirstResultZeroAndMaxResultsWithoutOrder(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name = :name" )
+ .createSelectionQuery( "from Flour where name = :name", Flour.class )
.setParameter( "name", almond.getName() )
.setFirstResult( 0 )
.setMaxResults( 10 )
@@ -181,7 +181,7 @@ public void testFirstResultZeroAndMaxResultsWithoutOrder(VertxTestContext contex
public void testFirstResultMaxResultsMultipleResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 2 )
.getResultList()
@@ -194,7 +194,7 @@ public void testFirstResultMaxResultsMultipleResults(VertxTestContext context) {
public void testFirstResultMaxResultsExtra(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 3 )
.getResultList()
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedTest.java
index cd8bc7679..f4ff747f9 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterNamedTest.java
@@ -21,9 +21,7 @@
import jakarta.persistence.Table;
import static java.util.concurrent.TimeUnit.MINUTES;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests queries using named parameters like ":name",
@@ -50,15 +48,20 @@ public void populateDb(VertxTestContext context) {
@Test
public void testAutoFlushOnSingleResult(VertxTestContext context) {
- Flour semolina = new Flour(678, "Semoline", "the coarse, purified wheat middlings of durum wheat used in making pasta.", "Wheat flour" );
+ Flour semolina = new Flour(
+ 678,
+ "Semoline",
+ "the coarse, purified wheat middlings of durum wheat used in making pasta.",
+ "Wheat flour"
+ );
test( context, getSessionFactory()
.withSession( s -> s
.persist( semolina )
- .thenCompose( v -> s.createQuery( "from Flour where id = :id" )
+ .thenCompose( v -> s.createSelectionQuery( "from Flour where id = :id", Flour.class )
.setParameter( "id", semolina.getId() )
.getSingleResult()
)
- .thenAccept( found -> assertEquals( semolina, found ) )
+ .thenAccept( found -> assertThat( found ).isEqualTo( semolina ) )
)
);
}
@@ -66,119 +69,125 @@ public void testAutoFlushOnSingleResult(VertxTestContext context) {
@Test
public void testSelectScalarValues(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "SELECT 'Prova' FROM Flour WHERE id = :id" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "SELECT 'Prova' FROM Flour WHERE id = :id",
+ String.class
+ )
.setParameter( "id", rye.getId() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( found -> assertEquals( "Prova", found ) )
+ } ).thenAccept( found -> assertThat( found ).isEqualTo( "Prova" ) )
);
}
@Test
public void testSelectWithMultipleScalarValues(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = :id" )
- .setParameter( "id", rye.getId() );
- assertNotNull( qr );
- return qr.getSingleResult();
- } ).thenAccept( found -> {
- assertTrue( found instanceof Object[] );
- assertEquals( "Prova", ( (Object[]) found )[0] );
- assertEquals( rye.getId(), ( (Object[]) found )[1] );
- } )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "SELECT 'Prova', f.id FROM Flour f WHERE f.id = :id",
+ Object[].class
+ )
+ .setParameter( "id", rye.getId() );
+ assertThat( qr ).isNotNull();
+ return qr.getSingleResult();
+ } )
+ .thenAccept( found -> assertThat( found )
+ .containsExactly( "Prova", rye.getId() ) )
);
}
@Test
public void testSingleResultQueryOnId(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE id = :id" )
+ Stage.SelectionQuery qr = s
+ .createSelectionQuery( "FROM Flour WHERE id = :id", Flour.class )
.setParameter( "id", 1 );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( flour -> assertEquals( spelt, flour ) )
+ } ).thenAccept( flour -> assertThat( flour ).isEqualTo( spelt ) )
);
}
@Test
public void testSingleResultQueryOnName(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = :name" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE name = :name", Flour.class )
.setParameter( "name", "Almond" );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( flour -> assertEquals( almond, flour ) )
+ } ).thenAccept( flour -> assertThat( flour ).isEqualTo( almond ) )
);
}
@Test
public void testSingleResultMultipleParameters(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = :name and description = :desc" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "FROM Flour WHERE name = :name and description = :desc",
+ Flour.class
+ )
.setParameter( "name", almond.getName() )
.setParameter( "desc", almond.getDescription() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( flour -> assertEquals( almond, flour ) )
+ } ).thenAccept( flour -> assertThat( flour ).isEqualTo( almond ) )
);
}
@Test
public void testSingleResultMultipleParametersReversed(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = :name and description = :desc" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "FROM Flour WHERE name = :name and description = :desc",
+ Flour.class
+ )
.setParameter( "desc", almond.getDescription() )
.setParameter( "name", almond.getName() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( flour -> assertEquals( almond, flour ) )
+ } ).thenAccept( flour -> assertThat( flour ).isEqualTo( almond ) )
);
}
@Test
public void testSingleResultMultipleParametersReused(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = :name or cast(:name as string) is null" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "FROM Flour WHERE name = :name or cast(:name as string) is null",
+ Flour.class
+ )
.setParameter( "name", almond.getName() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( flour -> assertEquals( almond, flour ) )
+ } ).thenAccept( flour -> assertThat( flour ).isEqualTo( almond ) )
);
}
@Test
public void testPlaceHolderInString(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "select ':', ':name', f FROM Flour f WHERE f.name = :name" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "select ':', ':name', f FROM Flour f WHERE f.name = :name",
+ Object[].class
+ )
.setParameter( "name", almond.getName() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( result -> {
- assertEquals( Object[].class, result.getClass() );
- final Object[] objects = (Object[]) result;
- assertEquals( 3, objects.length );
- assertEquals( ":", objects[0] );
- assertEquals( ":name", objects[1] );
- assertEquals( almond, objects[2] );
- } )
+ } ).thenAccept( result -> assertThat( result ).containsExactly( ":", ":name", almond ) )
);
}
@Test
public void testPlaceHolderAndSingleQuoteInString(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "select ''':', ''':name''', f FROM Flour f WHERE f.name = :name" )
+ Stage.SelectionQuery qr = s.createSelectionQuery(
+ "select ''':', ''':name''', f FROM Flour f WHERE f.name = :name",
+ Object[].class
+ )
.setParameter( "name", almond.getName() );
- assertNotNull( qr );
+ assertThat( qr ).isNotNull();
return qr.getSingleResult();
- } ).thenAccept( result -> {
- assertEquals( Object[].class, result.getClass() );
- final Object[] objects = (Object[]) result;
- assertEquals( 3, objects.length );
- assertEquals( "':", objects[0] );
- assertEquals( "':name'", objects[1] );
- assertEquals( almond, objects[2] );
- } )
+ } ).thenAccept( result -> assertThat( result ).containsExactly( "':", "':name'", almond ) )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java
index 1a4126463..af24ec69f 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalLimitTest.java
@@ -61,7 +61,7 @@ public void populateDb(VertxTestContext context) {
public void testNoResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where id = ?1" ).setMaxResults( 0 )
+ .createSelectionQuery( "from Flour where id = ?1", Flour.class ).setMaxResults( 0 )
.setParameter( 1, rye.getId() )
.getResultList()
.thenAccept( list -> assertEquals( 0, list.size() ) )
@@ -73,7 +73,7 @@ public void testNoResults(VertxTestContext context) {
public void testFirstResultNoResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour" )
+ .createSelectionQuery( "from Flour", Flour.class )
.setMaxResults( 0 )
.setFirstResult( 1 )
.getResultList()
@@ -86,7 +86,7 @@ public void testFirstResultNoResults(VertxTestContext context) {
public void testFirstResultSingleResult(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name != ?1 order by id" )
+ .createSelectionQuery( "from Flour where name != ?1 order by id", Flour.class )
.setParameter( 1, spelt.getName() )
.setFirstResult( 1 )
.getSingleResult()
@@ -99,7 +99,7 @@ public void testFirstResultSingleResult(VertxTestContext context) {
public void testFirstResultMultipleResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.getResultList()
.thenAccept( results -> assertThat( results ).containsExactly( rye, almond ) )
@@ -111,7 +111,7 @@ public void testFirstResultMultipleResults(VertxTestContext context) {
public void testFirstResultMaxResultsSingleResult(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 1 )
.getSingleResult()
@@ -127,7 +127,7 @@ public void testFirstResultMaxResultsSingleResult(VertxTestContext context) {
public void testFirstResultZeroAndMaxResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name = ?1 order by id" )
+ .createSelectionQuery( "from Flour where name = ?1 order by id", Flour.class )
.setParameter( 1, almond.getName() )
.setFirstResult( 0 )
.setMaxResults( 10 )
@@ -145,7 +145,7 @@ public void testFirstResultZeroAndMaxResults(VertxTestContext context) {
public void testFirstResultZeroAndMaxResultsWithoutOrder(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour where name = ?1" )
+ .createSelectionQuery( "from Flour where name = ?1", Flour.class )
.setParameter( 1, almond.getName() )
.setFirstResult( 0 )
.setMaxResults( 10 )
@@ -159,7 +159,7 @@ public void testFirstResultZeroAndMaxResultsWithoutOrder(VertxTestContext contex
public void testFirstResultMaxResultsMultipleResults(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s
- .createQuery( "from Flour order by id" )
+ .createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 2 )
.getResultList()
@@ -174,7 +174,7 @@ public void testFirstResultMaxResultsExtra(VertxTestContext context) {
context,
openSession()
.thenCompose( s ->
- s.createQuery( "from Flour order by id" )
+ s.createSelectionQuery( "from Flour order by id", Flour.class )
.setFirstResult( 1 )
.setMaxResults( 3 )
.getResultList()
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalTest.java
index 2d084a7ee..bd6e5b69f 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryParameterPositionalTest.java
@@ -23,7 +23,6 @@
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests queries using positional parameters like "?1, ?2, ...",
@@ -56,7 +55,7 @@ public void testAutoFlushOnSingleResult(VertxTestContext context) {
Flour semolina = new Flour( 678, "Semoline", "the coarse, purified wheat middlings of durum wheat used in making pasta.", "Wheat flour" );
test( context, getSessionFactory().withSession( s -> s
.persist( semolina )
- .thenCompose( v -> s.createQuery( "from Flour where id = ?1" )
+ .thenCompose( v -> s.createSelectionQuery( "from Flour where id = ?1", Flour.class )
.setParameter( 1, semolina.getId() )
.getSingleResult() )
.thenAccept( found -> assertEquals( semolina, found ) )
@@ -66,7 +65,7 @@ public void testAutoFlushOnSingleResult(VertxTestContext context) {
@Test
public void testSelectScalarValues(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "SELECT 'Prova' FROM Flour WHERE id = ?1" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "SELECT 'Prova' FROM Flour WHERE id = ?1", String.class )
.setParameter( 1, rye.getId() );
assertNotNull( qr );
return qr.getSingleResult();
@@ -77,14 +76,13 @@ public void testSelectScalarValues(VertxTestContext context) {
@Test
public void testSelectWithMultipleScalarValues(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = ?1" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = ?1", Object[].class )
.setParameter( 1, rye.getId() );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( found -> {
- assertTrue( found instanceof Object[] );
- assertEquals( "Prova", ( (Object[]) found )[0] );
- assertEquals( rye.getId(), ( (Object[]) found )[1] );
+ assertEquals( "Prova", found[0]);
+ assertEquals( rye.getId(), found[1] );
} )
);
}
@@ -92,7 +90,7 @@ public void testSelectWithMultipleScalarValues(VertxTestContext context) {
@Test
public void testSingleResultQueryOnId(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE id = ?1" ).setParameter( 1, 1);
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE id = ?1", Flour.class ).setParameter( 1, 1);
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( flour -> assertEquals( spelt, flour ) )
@@ -102,7 +100,7 @@ public void testSingleResultQueryOnId(VertxTestContext context) {
@Test
public void testSingleResultQueryOnName(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = ?1" ).setParameter( 1, "Almond" );
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE name = ?1", Flour.class ).setParameter( 1, "Almond" );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( flour -> assertEquals( almond, flour ) )
@@ -112,7 +110,7 @@ public void testSingleResultQueryOnName(VertxTestContext context) {
@Test
public void testSingleResultMultipleParameters(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = ?1 and description = ?2" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE name = ?1 and description = ?2", Flour.class )
.setParameter( 1, almond.getName() )
.setParameter( 2, almond.getDescription() );
assertNotNull( qr );
@@ -124,7 +122,7 @@ public void testSingleResultMultipleParameters(VertxTestContext context) {
@Test
public void testSingleResultMultipleParametersReversed(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = ?2 and description = ?1" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE name = ?2 and description = ?1", Flour.class )
.setParameter( 2, almond.getName() )
.setParameter( 1, almond.getDescription() );
assertNotNull( qr );
@@ -136,7 +134,7 @@ public void testSingleResultMultipleParametersReversed(VertxTestContext context)
@Test
public void testSingleResultMultipleParametersReused(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour WHERE name = ?1 or cast(?1 as string) is null" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour WHERE name = ?1 or cast(?1 as string) is null", Flour.class )
.setParameter( 1, almond.getName() );
assertNotNull( qr );
return qr.getSingleResult();
@@ -147,17 +145,15 @@ public void testSingleResultMultipleParametersReused(VertxTestContext context) {
@Test
public void testPlaceHolderInString(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "select '?', '?1', f FROM Flour f WHERE f.name = ?1" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "select '?', '?1', f FROM Flour f WHERE f.name = ?1", Object[].class )
.setParameter( 1, almond.getName() );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( result -> {
- assertEquals( Object[].class, result.getClass() );
- final Object[] objects = (Object[]) result;
- assertEquals( 3, objects.length );
- assertEquals( "?", objects[0] );
- assertEquals( "?1", objects[1] );
- assertEquals( almond, objects[2] );
+ assertEquals( 3, result.length );
+ assertEquals( "?", result[0] );
+ assertEquals( "?1", result[1] );
+ assertEquals( almond, result[2] );
} )
);
}
@@ -165,17 +161,15 @@ public void testPlaceHolderInString(VertxTestContext context) {
@Test
public void testPlaceHolderAndSingleQuoteInString(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "select '''?', '''?1''', f FROM Flour f WHERE f.name = ?1" )
+ Stage.SelectionQuery qr = s.createSelectionQuery( "select '''?', '''?1''', f FROM Flour f WHERE f.name = ?1", Object[].class )
.setParameter( 1, almond.getName() );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( result -> {
- assertEquals( Object[].class, result.getClass() );
- final Object[] objects = (Object[]) result;
- assertEquals( 3, objects.length );
- assertEquals( "'?", objects[0] );
- assertEquals( "'?1'", objects[1] );
- assertEquals( almond, objects[2] );
+ assertEquals( 3, result.length );
+ assertEquals( "'?", result[0] );
+ assertEquals( "'?1'", result[1] );
+ assertEquals( almond, result[2] );
} )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryTest.java
index d1a6d56cc..e48d3ec69 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLQueryTest.java
@@ -50,7 +50,7 @@ public void testAutoFlushOnSingleResult(VertxTestContext context) {
Flour semolina = new Flour( 678, "Semoline", "the coarse, purified wheat middlings of durum wheat used in making pasta.", "Wheat flour" );
test( context, getSessionFactory().withTransaction( s -> s
.persist( semolina )
- .thenCompose( v -> s.createQuery( "from Flour where id = " + semolina.getId() ).getSingleResult() )
+ .thenCompose( v -> s.createSelectionQuery( "from Flour where id = " + semolina.getId(), Flour.class ).getSingleResult() )
.thenAccept( found -> assertEquals( semolina, found ) ) )
);
}
@@ -60,7 +60,7 @@ public void testAutoFlushOnResultList(VertxTestContext context) {
Flour semolina = new Flour( 678, "Semoline", "the coarse, purified wheat middlings of durum wheat used in making pasta.", "Wheat flour" );
test( context, getSessionFactory().withTransaction( s -> s
.persist( semolina )
- .thenCompose( v -> s.createQuery( "from Flour order by name" ).getResultList() )
+ .thenCompose( v -> s.createSelectionQuery( "from Flour order by name", Flour.class ).getResultList() )
.thenAccept( results -> assertThat( results ).containsExactly( almond, rye, semolina, spelt ) )
) );
}
@@ -68,7 +68,7 @@ public void testAutoFlushOnResultList(VertxTestContext context) {
@Test
public void testSelectScalarString(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query qr = s.createQuery( "SELECT 'Prova' FROM Flour WHERE id = " + rye.getId() );
+ Stage.SelectionQuery qr = s.createSelectionQuery( "SELECT 'Prova' FROM Flour WHERE id = " + rye.getId(), String.class );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( found -> assertEquals( "Prova", found ) ) );
@@ -77,7 +77,7 @@ public void testSelectScalarString(VertxTestContext context) {
@Test
public void testSelectScalarCount(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.SelectionQuery qr = s.createQuery( "SELECT count(*) FROM Flour", Long.class );
+ Stage.SelectionQuery qr = s.createSelectionQuery( "SELECT count(*) FROM Flour", Long.class );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( found -> assertEquals( 3L, found ) ) );
@@ -86,7 +86,7 @@ public void testSelectScalarCount(VertxTestContext context) {
@Test
public void testSelectWithMultipleScalarValues(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query> qr = s.createQuery( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = " + rye.getId() );
+ Stage.SelectionQuery> qr = s.createSelectionQuery( "SELECT 'Prova', f.id FROM Flour f WHERE f.id = " + rye.getId(), Object[].class );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( found -> {
@@ -100,7 +100,7 @@ public void testSelectWithMultipleScalarValues(VertxTestContext context) {
@Test
public void testSingleResultQueryOnId(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query> qr = s.createQuery( "FROM Flour WHERE id = 1" );
+ Stage.SelectionQuery> qr = s.createSelectionQuery( "FROM Flour WHERE id = 1", Flour.class );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( flour -> assertEquals( spelt, flour ) )
@@ -110,7 +110,7 @@ public void testSingleResultQueryOnId(VertxTestContext context) {
@Test
public void testSingleResultQueryOnName(VertxTestContext context) {
test( context, getSessionFactory().withSession( s -> {
- Stage.Query> qr = s.createQuery( "FROM Flour WHERE name = 'Almond'" );
+ Stage.SelectionQuery> qr = s.createSelectionQuery( "FROM Flour WHERE name = 'Almond'", Flour.class );
assertNotNull( qr );
return qr.getSingleResult();
} ).thenAccept( flour -> assertEquals( almond, flour ) )
@@ -121,7 +121,7 @@ public void testSingleResultQueryOnName(VertxTestContext context) {
public void testFromQuery(VertxTestContext context) {
test( context, getSessionFactory()
.withSession( s -> {
- Stage.Query qr = s.createQuery( "FROM Flour ORDER BY name" );
+ Stage.SelectionQuery qr = s.createSelectionQuery( "FROM Flour ORDER BY name", Flour.class );
assertNotNull( qr );
return qr.getResultList();
} )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLUpdateQueryTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLUpdateQueryTest.java
index 48e39a505..00b8ec869 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLUpdateQueryTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/HQLUpdateQueryTest.java
@@ -47,7 +47,7 @@ public void testUpdateQuery(VertxTestContext context) {
test(
context,
openSession()
- .thenApply( s -> s.createQuery( "UPDATE Flour SET description = '" + updatedDescription + "' WHERE id = " + rye.getId() ) )
+ .thenApply( s -> s.createMutationQuery( "UPDATE Flour SET description = '" + updatedDescription + "' WHERE id = " + rye.getId() ) )
.thenCompose( qr -> {
assertNotNull( qr );
return qr.executeUpdate();
@@ -65,7 +65,7 @@ public void testUpdateQueryWithParameters(VertxTestContext context) {
test(
context,
openSession()
- .thenApply( s -> s.createQuery( "UPDATE Flour SET description = :updatedDescription WHERE id = :id" )
+ .thenApply( s -> s.createMutationQuery( "UPDATE Flour SET description = :updatedDescription WHERE id = :id" )
.setParameter("updatedDescription", updatedDescription)
.setParameter("id", rye.getId()) )
.thenCompose( qr -> {
@@ -112,7 +112,7 @@ public void testDeleteQuery(VertxTestContext context) {
test(
context,
openSession()
- .thenApply( s -> s.createQuery( "DELETE FROM Flour WHERE id = " + rye.getId() ) )
+ .thenApply( s -> s.createMutationQuery( "DELETE FROM Flour WHERE id = " + rye.getId() ) )
.thenCompose( qr -> {
assertNotNull( qr );
return qr.executeUpdate();
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorDynamicInsertTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorDynamicInsertTest.java
index 97bfb59d2..2454de0d3 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorDynamicInsertTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorDynamicInsertTest.java
@@ -84,7 +84,7 @@ public void testIdentityGenerator(VertxTestContext context) {
test( context, populateDb()
.thenCompose( v -> openSession() )
.thenCompose( session ->
- session.createQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
+ session.createSelectionQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
.getResultList() )
.thenAccept( list -> {
assertEquals( ENTITY_NUMBER, list.size() );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTest.java
index 4e6280ac4..61cc6c503 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorTest.java
@@ -83,7 +83,7 @@ public void testIdentityGenerator(VertxTestContext context) {
test( context, populateDb()
.thenCompose( v -> openSession() )
.thenCompose( session -> session
- .createQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
+ .createSelectionQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
.getResultList() )
.thenAccept( list -> {
assertEquals( ENTITY_NUMBER, list.size() );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorWithColumnTransformerTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorWithColumnTransformerTest.java
index 487c53d87..3982e0c6b 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorWithColumnTransformerTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/IdentityGeneratorWithColumnTransformerTest.java
@@ -88,7 +88,7 @@ public void testIdentityGenerator(VertxTestContext context) {
test( context, populateDb()
.thenCompose( v -> openSession() )
.thenCompose( session ->
- session.createQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
+ session.createSelectionQuery( "FROM EntityWithIdentity ORDER BY position ASC", EntityWithIdentity.class )
.getResultList() )
.thenAccept( list -> {
assertEquals( ENTITY_NUMBER, list.size() );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java
index 3c97f70f5..2b0e3f9c6 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java
@@ -132,9 +132,9 @@ public void testQueryUpdate(VertxTestContext context) {
openSession()
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
.thenCompose( vv -> openSession()
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() )
- .thenCompose( v -> s.withTransaction( t -> s.createQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
- .thenCompose( v -> s.withTransaction( t -> s.createQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() )
+ .thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
+ .thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
.thenCompose( v -> s.find(Book.class, 6) )
.thenAccept( book -> {
assertNotNull(book);
@@ -143,7 +143,7 @@ public void testQueryUpdate(VertxTestContext context) {
} )
) )
.thenCompose( vv -> openSession()
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
.thenCompose( v -> openSession() )
.thenCompose( s -> s.find(Book.class, 6) )
.thenAccept( Assertions::assertNull )
@@ -160,13 +160,13 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
openSession()
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession()
- .thenCompose( s-> s.withTransaction( t -> s.createQuery("update SpellBook set forbidden=:fob where title=:tit")
+ .thenCompose( s-> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=:fob where title=:tit")
.setParameter("fob", false)
.setParameter("tit", "Necronomicon")
.executeUpdate() )
) )
.thenCompose( v -> openSession()
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update Book set title=title||:sfx where title=:tit")
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||:sfx where title=:tit")
.setParameter("sfx", " II")
.setParameter("tit", "Necronomicon")
.executeUpdate() )
@@ -181,7 +181,7 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
)
)
.thenCompose( v -> openSession()
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("delete Book where title=:tit")
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title=:tit")
.setParameter("tit", "Necronomicon II")
.executeUpdate() )
) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyInitializationExceptionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyInitializationExceptionTest.java
index aabc86cd8..bb04c0fda 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyInitializationExceptionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyInitializationExceptionTest.java
@@ -64,7 +64,7 @@ public void populateDB(VertxTestContext context) {
@Test
public void testLazyInitializationExceptionWithMutiny(VertxTestContext context) {
test( context, assertThrown( LazyInitializationException.class, openMutinySession()
- .chain( ms -> ms.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .chain( ms -> ms.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
.invoke( artist -> artist.getPaintings().size() ) )
.invoke( LazyInitializationExceptionTest::assertLazyInitialization )
);
@@ -73,7 +73,7 @@ public void testLazyInitializationExceptionWithMutiny(VertxTestContext context)
@Test
public void testLazyInitializationExceptionWithStage(VertxTestContext context) {
test( context, assertThrown( LazyInitializationException.class, openSession()
- .thenCompose( ss -> ss.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .thenCompose( ss -> ss.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
.thenAccept( artist -> artist.getPaintings().size() ) )
.thenAccept( LazyInitializationExceptionTest::assertLazyInitialization )
);
@@ -87,7 +87,7 @@ private static void assertLazyInitialization(LazyInitializationException e) {
@Test
public void testLazyInitializationExceptionNotThrownWithMutiny(VertxTestContext context) {
test( context, openMutinySession()
- .chain( session -> session.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .chain( session -> session.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
// We are checking `.getPaintings()` but not doing anything with it and therefore it should work.
.invoke( Artist::getPaintings )
);
@@ -96,7 +96,7 @@ public void testLazyInitializationExceptionNotThrownWithMutiny(VertxTestContext
@Test
public void testLazyInitializationExceptionNotThrownWithStage(VertxTestContext context) {
test( context, openSession()
- .thenCompose( session -> session.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .thenCompose( session -> session.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
// We are checking `.getPaintings()` but not doing anything with it and therefore it should work.
.thenAccept( Artist::getPaintings )
);
@@ -105,7 +105,7 @@ public void testLazyInitializationExceptionNotThrownWithStage(VertxTestContext c
@Test
public void testLazyInitializationWithJoinFetchAndMutiny(VertxTestContext context) {
test( context, openMutinySession()
- .chain( session -> session.createQuery( "from Artist a join fetch a.paintings", Artist.class ).getSingleResult() )
+ .chain( session -> session.createSelectionQuery( "from Artist a join fetch a.paintings", Artist.class ).getSingleResult() )
.onItem().invoke( artist -> {
assertTrue( Hibernate.isInitialized( artist ) );
assertEquals( 2, artist.getPaintings().size() );
@@ -116,7 +116,7 @@ public void testLazyInitializationWithJoinFetchAndMutiny(VertxTestContext contex
public void testLazyInitializationWithJoinFetch(VertxTestContext context) {
test( context, openSession()
.thenCompose( session -> session
- .createQuery( "from Artist a join fetch a.paintings", Artist.class )
+ .createSelectionQuery( "from Artist a join fetch a.paintings", Artist.class )
.getSingleResult() )
.thenAccept( artist -> {
assertTrue( Hibernate.isInitialized( artist.paintings ) );
@@ -127,7 +127,7 @@ public void testLazyInitializationWithJoinFetch(VertxTestContext context) {
@Test
public void testLazyInitializationWithMutinyFetch(VertxTestContext context) {
test( context, openMutinySession()
- .chain( session -> session.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .chain( session -> session.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
.chain( artist -> Mutiny.fetch( artist.paintings )
.invoke( paintings -> {
assertTrue( Hibernate.isInitialized( paintings ) );
@@ -140,7 +140,7 @@ public void testLazyInitializationWithMutinyFetch(VertxTestContext context) {
@Test
public void testLazyInitializationWithStageFetch(VertxTestContext context) {
test( context, openSession()
- .thenCompose( session -> session.createQuery( "from Artist", Artist.class ).getSingleResult() )
+ .thenCompose( session -> session.createSelectionQuery( "from Artist", Artist.class ).getSingleResult() )
.thenCompose( artist -> Stage.fetch( artist.paintings )
.thenAccept( paintings -> {
assertTrue( Hibernate.isInitialized( paintings ) );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java
index 208097739..97662d66d 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToManyAssociationWithFetchTest.java
@@ -195,7 +195,7 @@ public void queryBookWithNamedEntityGraphFetchAuthors(VertxTestContext context)
.thenCompose( v -> s.persist( terryPratchett ) )
.thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "from Tome b where b.id=?1", Book.class )
+ .thenCompose( s -> s.createSelectionQuery( "from Tome b where b.id=?1", Book.class )
.setPlan( s.getEntityGraph( Book.class, "withAuthors" ) )
.setParameter( 1, goodOmens.getId() )
.getSingleResult() )
@@ -210,7 +210,7 @@ public void queryBookWithNamedEntityGraphFetchAuthors(VertxTestContext context)
.thenCompose( s -> {
EntityGraph graph = s.createEntityGraph( Author.class );
graph.addAttributeNodes( "book" );
- return s.createQuery( "from Writer w where w.id=?1", Author.class )
+ return s.createSelectionQuery( "from Writer w where w.id=?1", Author.class )
.setPlan( graph )
.setParameter( 1, neilGaiman.getId() )
.getSingleResult();
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToOneWithJoinColumnTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToOneWithJoinColumnTest.java
index 23d7b833f..a71f2c028 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToOneWithJoinColumnTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOneToOneWithJoinColumnTest.java
@@ -85,7 +85,7 @@ public void testQuery(VertxTestContext context) {
.call( session::flush ) )
.chain( this::openMutinySession )
.chain( session -> session
- .createQuery( query, Endpoint.class )
+ .createSelectionQuery( query, Endpoint.class )
.setParameter( "id", endpoint.getId() )
.setParameter( "accountId", endpoint.getAccountId() )
.getSingleResultOrNull()
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOrderedElementCollectionForEmbeddableTypeListTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOrderedElementCollectionForEmbeddableTypeListTest.java
index 225ff5895..7487be84d 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOrderedElementCollectionForEmbeddableTypeListTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyOrderedElementCollectionForEmbeddableTypeListTest.java
@@ -90,7 +90,7 @@ public void persistWithMutinyAPI(VertxTestContext context) {
public void joinFetch(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( (session, tx) -> session
- .createQuery( "from Person p join fetch p.phones", Person.class )
+ .createSelectionQuery( "from Person p join fetch p.phones", Person.class )
.getSingleResult().invoke( result -> {
assertTrue( Hibernate.isInitialized( result.phones ) );
assertPhones( result.phones, "111-111-1111", "999-999-9999" );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyMapTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyMapTest.java
index 1f6c8fa1e..4c94668d5 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyMapTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyMapTest.java
@@ -72,7 +72,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManySetTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManySetTest.java
index 9557fd103..51c90eda3 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManySetTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManySetTest.java
@@ -66,7 +66,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyTest.java
index 14618746e..0a6406534 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToManyTest.java
@@ -57,7 +57,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToOneMergeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToOneMergeTest.java
index 12bedea82..01c5d1d02 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToOneMergeTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ManyToOneMergeTest.java
@@ -58,7 +58,7 @@ public void populateDb(VertxTestContext context) {
@Test
public void test(VertxTestContext context) {
test( context, getMutinySessionFactory().withSession( session -> session
- .createQuery( "select dbo from AcademicYearDetailsDBO dbo", AcademicYearDetailsDBO.class )
+ .createSelectionQuery( "select dbo from AcademicYearDetailsDBO dbo", AcademicYearDetailsDBO.class )
.getSingleResult() )
.invoke( dbo -> dbo.setRecordStatus( 'A' ) )
.chain( dbo -> getMutinySessionFactory().withTransaction( session -> {
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultilineImportsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultilineImportsTest.java
index b3c32432f..29fbbcef6 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultilineImportsTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MultilineImportsTest.java
@@ -34,7 +34,7 @@
public class MultilineImportsTest extends BaseReactiveTest {
private static CompletionStage> runQuery(Stage.Session s) {
- return s.createQuery( "from Hero h where h.heroName = :name" )
+ return s.createSelectionQuery( "from Hero h where h.heroName = :name", Object.class )
.setParameter( "name", "Galadriel" )
.getResultList();
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java
index 3bd50778a..604b08f6a 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/MutinySessionTest.java
@@ -79,7 +79,7 @@ public void sessionClear(VertxTestContext context) {
// If the previous clear doesn't work, this will cause a duplicated entity exception
.chain( () -> session.persist( guineaPig ) )
.call( session::flush )
- .chain( () -> session.createQuery( "FROM GuineaPig", GuineaPig.class )
+ .chain( () -> session.createSelectionQuery( "FROM GuineaPig", GuineaPig.class )
// By not using .find() we check that there is only one entity in the db with getSingleResult()
.getSingleResult() )
.invoke( result -> assertThatPigsAreEqual( guineaPig, result ) )
@@ -456,7 +456,7 @@ public void reactiveQueryWithLock(VertxTestContext context) {
context,
populateDB()
.call( () -> getMutinySessionFactory().withTransaction(
- (session, tx) -> session.createQuery( "from GuineaPig pig", GuineaPig.class)
+ (session, tx) -> session.createSelectionQuery( "from GuineaPig pig", GuineaPig.class)
.setLockMode( LockModeType.PESSIMISTIC_WRITE )
.getSingleResult()
.invoke( actualPig -> {
@@ -474,7 +474,7 @@ public void reactiveQueryWithAliasedLock(VertxTestContext context) {
context,
populateDB()
.call( () -> getMutinySessionFactory().withTransaction(
- (session, tx) -> session.createQuery( "from GuineaPig pig", GuineaPig.class)
+ (session, tx) -> session.createSelectionQuery( "from GuineaPig pig", GuineaPig.class)
.setLockMode("pig", LockMode.PESSIMISTIC_WRITE )
.getSingleResult()
.invoke( actualPig -> {
@@ -496,7 +496,7 @@ public void reactiveMultiQuery(VertxTestContext context) {
getMutinySessionFactory()
.withTransaction( (session, transaction) -> session.persistAll(foo, bar, baz) )
.call( () -> getMutinySessionFactory().withSession(
- session -> session.createQuery("from GuineaPig", GuineaPig.class)
+ session -> session.createSelectionQuery("from GuineaPig", GuineaPig.class)
.getResultList().onItem().disjoint()
.invoke( pig -> {
assertNotNull(pig);
@@ -541,7 +541,7 @@ public void testMetamodel() {
@Test
public void testTransactionPropagation(VertxTestContext context) {
test( context, getMutinySessionFactory().withTransaction(
- (session, transaction) -> session.createQuery("from GuineaPig").getResultList()
+ (session, transaction) -> session.createSelectionQuery("from GuineaPig", GuineaPig.class).getResultList()
.chain( list -> {
assertNotNull( session.currentTransaction() );
assertFalse( session.currentTransaction().isMarkedForRollback() );
@@ -550,7 +550,7 @@ public void testTransactionPropagation(VertxTestContext context) {
assertTrue( transaction.isMarkedForRollback() );
return session.withTransaction( t -> {
assertTrue( t.isMarkedForRollback() );
- return session.createQuery("from GuineaPig").getResultList();
+ return session.createSelectionQuery("from GuineaPig", GuineaPig.class).getResultList();
} );
} )
) );
@@ -561,10 +561,10 @@ public void testSessionPropagation(VertxTestContext context) {
test( context, getMutinySessionFactory().withSession( session -> {
assertFalse( session.isDefaultReadOnly() );
session.setDefaultReadOnly(true);
- return session.createQuery("from GuineaPig").getResultList()
+ return session.createSelectionQuery("from GuineaPig", GuineaPig.class).getResultList()
.chain( list -> getMutinySessionFactory().withSession(s -> {
assertTrue( s.isDefaultReadOnly() );
- return s.createQuery("from GuineaPig").getResultList();
+ return s.createSelectionQuery("from GuineaPig", GuineaPig.class).getResultList();
} ) );
} ) );
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NoVertxContextTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NoVertxContextTest.java
index 26468d3a2..ccd1c16de 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NoVertxContextTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NoVertxContextTest.java
@@ -71,7 +71,7 @@ public static void closeSessionFactory() {
public void deleteEntries() {
mutinyFactory()
.withTransaction( session -> session
- .createQuery( "delete from " + GameCharacter.ENTITY_NAME )
+ .createMutationQuery( "delete from " + GameCharacter.ENTITY_NAME )
.executeUpdate() )
.await().indefinitely();
}
@@ -91,7 +91,7 @@ public void testWithStage() {
assertThat( found.name ).isEqualTo( namePrefix + ENTRIES_NUM );
} )
.thenCompose( v -> stageFactory().withSession( session -> session
- .createQuery( "select count(*) from " + GameCharacter.ENTITY_NAME )
+ .createSelectionQuery( "select count(*) from " + GameCharacter.ENTITY_NAME, Long.class )
.getSingleResult() ) )
.thenAccept( count -> assertThat( count ).isEqualTo( Long.valueOf( ENTRIES_NUM ) ) )
.toCompletableFuture().join();
@@ -122,7 +122,7 @@ public void testWithMutiny() {
assertThat( found.name ).isEqualTo( namePrefix + ENTRIES_NUM );
} )
.chain( () -> mutinyFactory().withSession( session -> session
- .createQuery( "select count(*) from " + GameCharacter.ENTITY_NAME ).getSingleResult() ) )
+ .createSelectionQuery( "select count(*) from " + GameCharacter.ENTITY_NAME, Long.class ).getSingleResult() ) )
.invoke( count -> assertThat( count ).isEqualTo( Long.valueOf( ENTRIES_NUM ) ) )
.await().indefinitely();
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NonNullableManyToOneTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NonNullableManyToOneTest.java
index 23728f459..67bb65326 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NonNullableManyToOneTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/NonNullableManyToOneTest.java
@@ -53,7 +53,7 @@ public void populateDB(VertxTestContext context) {
public void testNonNullableSuccess(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( session -> session
- .createQuery( "from Artist", Artist.class )
+ .createSelectionQuery( "from Artist", Artist.class )
.getSingleResult().chain( a -> session.fetch( a.getPaintings() ) )
.invoke( paintings -> {
assertNotNull( paintings );
@@ -62,7 +62,7 @@ public void testNonNullableSuccess(VertxTestContext context) {
} ) )
.chain( () -> getMutinySessionFactory()
.withTransaction( s1 -> s1
- .createQuery( "from Dealer", Dealer.class )
+ .createSelectionQuery( "from Dealer", Dealer.class )
.getSingleResult().chain( d -> s1.fetch( d.getPaintings() ) )
.invoke( paintings -> {
assertNotNull( paintings );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyMapTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyMapTest.java
index 516aa5a50..76c60b124 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyMapTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyMapTest.java
@@ -61,7 +61,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManySetTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManySetTest.java
index 07937f7cf..1abb81025 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManySetTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManySetTest.java
@@ -57,7 +57,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyTest.java
index 58e1692c1..c3bec53b1 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToManyTest.java
@@ -26,7 +26,6 @@
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -75,7 +74,7 @@ public void testFetchJoinQueryGetSingleResult(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( session -> session.persistAll( book1, book2, author ) )
.chain( () -> getMutinySessionFactory().withTransaction( session -> session
- .createQuery( "select distinct a from Author a left join fetch a.books", Author.class )
+ .createSelectionQuery( "select distinct a from Author a left join fetch a.books", Author.class )
.getSingleResult()
.invoke( a -> assertTrue( Hibernate.isInitialized( a.getBooks() ) ) )
.invoke( a -> assertThat( a.getBooks() ).containsExactlyInAnyOrder( book1, book2 ) )
@@ -94,7 +93,7 @@ public void testFetchJoinQueryGetSingleResultOrNull(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( session -> session.persistAll( book1, book2, author ) )
.chain( () -> getMutinySessionFactory().withTransaction( session -> session
- .createQuery( "select distinct a from Author a left join fetch a.books", Author.class )
+ .createSelectionQuery( "select distinct a from Author a left join fetch a.books", Author.class )
.getSingleResultOrNull()
.invoke( a -> assertTrue( Hibernate.isInitialized( a.getBooks() ) ) )
.invoke( a -> assertThat( a.getBooks() ).containsExactlyInAnyOrder( book1, book2 ) )
@@ -113,7 +112,7 @@ public void testFetchJoinQueryWithNull(VertxTestContext context) {
test( context, getMutinySessionFactory()
.withTransaction( session -> session.persistAll( book1, book2, author ) )
.chain( () -> getMutinySessionFactory().withTransaction( session -> session
- .createQuery( "select a from Author a left join fetch a.books where 1=0", Author.class )
+ .createSelectionQuery( "select a from Author a left join fetch a.books where 1=0", Author.class )
.getSingleResultOrNull()
.invoke( Assertions::assertNull )
) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToOnePrimaryKeyJoinColumnTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToOnePrimaryKeyJoinColumnTest.java
index 6cabf9540..37a6b0060 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToOnePrimaryKeyJoinColumnTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OneToOnePrimaryKeyJoinColumnTest.java
@@ -35,8 +35,8 @@ protected Collection> annotatedEntities() {
@AfterEach
public void cleanDb(VertxTestContext context) {
test( context, getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from PersonDetails" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Person" ).executeUpdate() ) ) );
+ .withTransaction( s -> s.createMutationQuery( "delete from PersonDetails" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Person" ).executeUpdate() ) ) );
}
@Test
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java
index e0aa5795f..509ce08fc 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedEmbeddableCollectionTest.java
@@ -66,7 +66,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
@@ -184,7 +184,7 @@ public void testMultipleRemovesFromCollection(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedManyToManyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedManyToManyTest.java
index f4e313665..2270b8437 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedManyToManyTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedManyToManyTest.java
@@ -57,7 +57,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedOneToManyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedOneToManyTest.java
index 3178e35d0..7edfa6e74 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedOneToManyTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrderedOneToManyTest.java
@@ -57,7 +57,7 @@ public void test(VertxTestContext context) {
)
)
.chain( () -> getMutinySessionFactory()
- .withTransaction( (session, transaction) -> session.createQuery(
+ .withTransaction( (session, transaction) -> session.createSelectionQuery(
"select distinct a from Author a left join fetch a.books",
Author.class
)
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java
index c9c6d4c97..7077fdbe5 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/OrphanRemovalTest.java
@@ -70,13 +70,13 @@ public void testOrphan(VertxTestContext context) {
) )
.thenCompose( v -> getSessionFactory()
.withTransaction( session -> session
- .createQuery( "select count(*) from Product", Long.class )
+ .createSelectionQuery( "select count(*) from Product", Long.class )
.getSingleResult()
.thenAccept( result -> assertEquals( 3L, result ) )
) )
.thenCompose( v -> getSessionFactory()
.withTransaction( session -> session
- .createQuery( "select name from Product" )
+ .createSelectionQuery( "select name from Product", String.class )
.getResultList()
.thenAccept( list -> assertThat( list )
.containsExactlyInAnyOrder( "bp5", "bp6", "bp7" ) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/PersistThenDeleteTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/PersistThenDeleteTest.java
index dd4ff5dc2..f2349135f 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/PersistThenDeleteTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/PersistThenDeleteTest.java
@@ -39,15 +39,15 @@ public void testPersistThenDelete(VertxTestContext context) {
.withTransaction( s -> s
.persist( newPerson( "foo" ), newPerson( "bar" ), newPerson( "baz" ) ) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
- .createQuery( "from Person" ).getResultList()
+ .createSelectionQuery( "from Person", Person.class ).getResultList()
.thenAccept( l -> assertThat( l ).hasSize( 3 ) )
) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
.persist( newPerson( "critical" ) )
- .thenCompose( vo -> s.createQuery( "delete from Person" ).executeUpdate() )
+ .thenCompose( vo -> s.createMutationQuery( "delete from Person" ).executeUpdate() )
) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
- .createQuery( "from Person" ).getResultList()
+ .createSelectionQuery( "from Person", Person.class ).getResultList()
.thenAccept( l -> assertThat( l ).isEmpty() )
) )
);
@@ -59,17 +59,17 @@ public void testDeleteThenPersist(VertxTestContext context) {
.withTransaction( s -> s
.persist( newPerson( "foo" ), newPerson( "bar" ), newPerson( "baz" ) ) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
- .createQuery( "from Person" )
+ .createSelectionQuery( "from Person", Person.class )
.getResultList()
.thenAccept( l -> assertThat( l ).hasSize( 3 ) )
) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
- .createQuery( "delete from Person" )
+ .createMutationQuery( "delete from Person" )
.executeUpdate()
.thenCompose( vo -> s.persist( newPerson( "critical" ) ) )
) )
.thenCompose( v -> getSessionFactory().withTransaction( s -> s
- .createQuery( "from Person" )
+ .createSelectionQuery( "from Person", Person.class )
.getResultList()
.thenAccept( l -> assertThat( l ).hasSize( 1 ) )
) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/QueryTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/QueryTest.java
index 13d309a3e..054264011 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/QueryTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/QueryTest.java
@@ -415,12 +415,12 @@ public void testNativeProjectionQuery(VertxTestContext context) {
} )
.thenCompose( v -> openSession() )
.thenCompose( session -> session
- .createQuery( "select title from Book", String.class )
+ .createSelectionQuery( "select title from Book", String.class )
.getResultList()
.thenAccept( list -> assertThat( list )
.containsExactlyInAnyOrder( book1.title, book2.title, book3.title ) )
.thenCompose( vv -> session
- .createQuery( "select title, isbn, id from Book", Object[].class )
+ .createSelectionQuery( "select title, isbn, id from Book", Object[].class )
.getResultList()
.thenAccept( list -> {
Object[] tuple = list.get( 0 );
@@ -496,7 +496,7 @@ public void testNamedHqlProjectionQuery(VertxTestContext context) {
} )
.thenCompose( v -> openSession() )
- .thenCompose( session -> session.createQuery( "update Book set title = ?1 where title = ?2" )
+ .thenCompose( session -> session.createMutationQuery( "update Book set title = ?1 where title = ?2" )
.setParameter( 1, "XXX" )
.setParameter( 2, "Snow Crash" )
.executeUpdate() )
@@ -558,7 +558,7 @@ private String selectCurrentTimestampQuery() {
@Test
public void testSingleResultQueryNull(VertxTestContext context) {
test( context, openSession()
- .thenCompose( s -> s.createQuery( "from Book" ).getSingleResultOrNull() )
+ .thenCompose( s -> s.createSelectionQuery( "from Book", Book.class ).getSingleResultOrNull() )
.thenAccept( Assertions::assertNull )
);
}
@@ -566,7 +566,7 @@ public void testSingleResultQueryNull(VertxTestContext context) {
@Test
public void testSingleResultQueryException(VertxTestContext context) {
test( context, openSession()
- .thenCompose( s -> s.createQuery( "from Book" ).getSingleResult() )
+ .thenCompose( s -> s.createSelectionQuery( "from Book", Book.class ).getSingleResult() )
.whenComplete( (r, x) -> {
assertNull( r );
assertNotNull( x );
@@ -588,7 +588,7 @@ public void testSingleResultNonUniqueException(VertxTestContext context) {
.thenCompose( v -> openSession() )
.thenCompose( s -> assertThrown(
jakarta.persistence.NonUniqueResultException.class,
- s.createQuery( "from Author" ).getSingleResult()
+ s.createSelectionQuery( "from Author", Author.class ).getSingleResult()
) )
);
}
@@ -602,7 +602,7 @@ public void testSingleResultOrNullNonUniqueException(VertxTestContext context) {
.thenCompose( v -> openSession() )
.thenCompose( s -> assertThrown(
jakarta.persistence.NonUniqueResultException.class,
- s.createQuery( "from Author" ).getSingleResultOrNull()
+ s.createSelectionQuery( "from Author", Author.class ).getSingleResultOrNull()
) )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java
index b47eed56e..959dc4ed7 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveSessionTest.java
@@ -90,7 +90,7 @@ public void sessionClear(VertxTestContext context) {
// If the previous clear doesn't work, this will cause a duplicated entity exception
.thenCompose( v -> session.persist( guineaPig ) )
.thenCompose( v -> session.flush() )
- .thenCompose( v -> session.createQuery( "FROM GuineaPig", GuineaPig.class )
+ .thenCompose( v -> session.createSelectionQuery( "FROM GuineaPig", GuineaPig.class )
// By not using .find() we check that there is only one entity in the db with getSingleResult()
.getSingleResult() )
.thenAccept( result -> assertThatPigsAreEqual( guineaPig, result ) )
@@ -271,7 +271,7 @@ public void reactiveFindThenForceLock(VertxTestContext context) {
);
assertEquals( actualPig.version, 1 );
} )
- .thenCompose( v -> session.createQuery( "select version from GuineaPig" )
+ .thenCompose( v -> session.createSelectionQuery( "select version from GuineaPig", Integer.class )
.getSingleResult() )
.thenAccept( version -> assertEquals( 1, version ) )
)
@@ -287,7 +287,7 @@ public void reactiveFindThenForceLock(VertxTestContext context) {
);
assertEquals( actualPig.version, 2 );
} )
- .thenCompose( v -> session.createQuery( "select version from GuineaPig" )
+ .thenCompose( v -> session.createSelectionQuery( "select version from GuineaPig", Integer.class )
.getSingleResult() )
.thenAccept( version -> assertEquals( 2, version ) )
)
@@ -540,7 +540,7 @@ public void reactiveQueryWithLock(VertxTestContext context) {
populateDB()
.thenCompose( v -> getSessionFactory()
.withTransaction( (session, tx) -> session
- .createQuery( "from GuineaPig pig", GuineaPig.class )
+ .createSelectionQuery( "from GuineaPig pig", GuineaPig.class )
.setLockMode( LockModeType.PESSIMISTIC_WRITE )
.getSingleResult()
.thenAccept( actualPig -> {
@@ -558,7 +558,7 @@ public void reactiveQueryWithAliasedLock(VertxTestContext context) {
test( context, populateDB()
.thenCompose(
v -> getSessionFactory().withTransaction(
- (session, tx) -> session.createQuery( "from GuineaPig pig", GuineaPig.class )
+ (session, tx) -> session.createSelectionQuery( "from GuineaPig pig", GuineaPig.class )
.setLockMode( "pig", LockMode.PESSIMISTIC_WRITE )
.getSingleResult()
.thenAccept( actualPig -> {
@@ -784,7 +784,7 @@ public void testMetamodel() {
@Test
public void testTransactionPropagation(VertxTestContext context) {
test( context, getSessionFactory().withTransaction(
- (session, transaction) -> session.createQuery( "from GuineaPig" ).getResultList()
+ (session, transaction) -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList()
.thenCompose( list -> {
assertNotNull( session.currentTransaction() );
assertFalse( session.currentTransaction().isMarkedForRollback() );
@@ -794,7 +794,7 @@ public void testTransactionPropagation(VertxTestContext context) {
return session.withTransaction( t -> {
assertEquals( t, transaction );
assertTrue( t.isMarkedForRollback() );
- return session.createQuery( "from GuineaPig" ).getResultList();
+ return session.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList();
} );
} )
) );
@@ -805,10 +805,10 @@ public void testSessionPropagation(VertxTestContext context) {
test( context, getSessionFactory().withSession( session -> {
assertFalse( session.isDefaultReadOnly() );
session.setDefaultReadOnly( true );
- return session.createQuery( "from GuineaPig" ).getResultList()
+ return session.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList()
.thenCompose( list -> getSessionFactory().withSession( s -> {
assertTrue( s.isDefaultReadOnly() );
- return s.createQuery( "from GuineaPig" ).getResultList();
+ return s.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList();
} ) );
} ) );
}
@@ -880,7 +880,7 @@ public void testCreateSelectionQueryMultiple(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s.withTransaction( t -> s.persist( aloiPig, bloiPig ) )
.thenCompose( v -> openSession() )
- .thenCompose( session -> session.createQuery( "from GuineaPig", GuineaPig.class )
+ .thenCompose( session -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class )
.getResultList()
.thenAccept( resultList -> assertThat( resultList ).containsExactlyInAnyOrder( aloiPig, bloiPig ) )
)
@@ -899,13 +899,13 @@ public void testCreateSelectionQuerySingle(VertxTestContext context) {
.thenCompose( s -> s
.withTransaction( t -> s.persist( new GuineaPig( 10, "Aloi" ) ) )
.thenCompose( v -> openSession() )
- .thenCompose( session -> session.createQuery( "from GuineaPig", GuineaPig.class )
+ .thenCompose( session -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class )
.getSingleResult()
.thenAccept( actualPig -> assertThatPigsAreEqual( expectedPig, actualPig ) ) )
.thenCompose( v -> openSession() )
.thenCompose( session -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class )
.getSingleResult()
- .thenAccept( actualPig -> assertThatPigsAreEqual( expectedPig, (GuineaPig) actualPig ) ) )
+ .thenAccept( actualPig -> assertThatPigsAreEqual( expectedPig, actualPig ) ) )
)
);
}
@@ -913,7 +913,7 @@ public void testCreateSelectionQuerySingle(VertxTestContext context) {
@Test
public void testCreateSelectionQueryNull(VertxTestContext context) {
test( context, openSession()
- .thenCompose( session -> session.createQuery( "from GuineaPig", GuineaPig.class )
+ .thenCompose( session -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class )
.getSingleResultOrNull()
.thenAccept( Assertions::assertNull ) )
.thenCompose( v -> openSession() )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveStatelessSessionTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveStatelessSessionTest.java
index ef270c7d3..c2f6ac31b 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveStatelessSessionTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/ReactiveStatelessSessionTest.java
@@ -45,7 +45,7 @@ public void testStatelessSession(VertxTestContext context) {
GuineaPig pig = new GuineaPig( "Aloi" );
test( context, getSessionFactory().withStatelessSession( ss -> ss
.insert( pig )
- .thenCompose( v -> ss.createQuery( "from GuineaPig where name=:n", GuineaPig.class )
+ .thenCompose( v -> ss.createSelectionQuery( "from GuineaPig where name=:n", GuineaPig.class )
.setParameter( "n", pig.name )
.getResultList() )
.thenAccept( list -> {
@@ -61,11 +61,11 @@ public void testStatelessSession(VertxTestContext context) {
} )
.thenCompose( v -> ss.refresh( pig ) )
.thenAccept( v -> assertEquals( pig.name, "X" ) )
- .thenCompose( v -> ss.createQuery( "update GuineaPig set name='Y'" ).executeUpdate() )
+ .thenCompose( v -> ss.createMutationQuery( "update GuineaPig set name='Y'" ).executeUpdate() )
.thenCompose( v -> ss.refresh( pig ) )
.thenAccept( v -> assertEquals( pig.name, "Y" ) )
.thenCompose( v -> ss.delete( pig ) )
- .thenCompose( v -> ss.createQuery( "from GuineaPig" ).getResultList() )
+ .thenCompose( v -> ss.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList() )
.thenAccept( list -> assertTrue( list.isEmpty() ) ) )
);
}
@@ -173,7 +173,7 @@ public void testStatelessSessionCriteria(VertxTestContext context) {
@Test
public void testTransactionPropagation(VertxTestContext context) {
test( context, getSessionFactory().withStatelessSession(
- session -> session.withTransaction( transaction -> session.createQuery( "from GuineaPig" )
+ session -> session.withTransaction( transaction -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class )
.getResultList()
.thenCompose( list -> {
assertNotNull( session.currentTransaction() );
@@ -183,7 +183,7 @@ public void testTransactionPropagation(VertxTestContext context) {
assertTrue( transaction.isMarkedForRollback() );
return session.withTransaction( t -> {
assertTrue( t.isMarkedForRollback() );
- return session.createQuery( "from GuineaPig" ).getResultList();
+ return session.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList();
} );
} ) )
) );
@@ -192,10 +192,10 @@ public void testTransactionPropagation(VertxTestContext context) {
@Test
public void testSessionPropagation(VertxTestContext context) {
test( context, getSessionFactory().withStatelessSession(
- session -> session.createQuery( "from GuineaPig" ).getResultList()
+ session -> session.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList()
.thenCompose( list -> getSessionFactory().withStatelessSession( s -> {
assertEquals( session, s );
- return s.createQuery( "from GuineaPig" ).getResultList();
+ return s.createSelectionQuery( "from GuineaPig", GuineaPig.class ).getResultList();
} ) )
) );
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SingleTableInheritanceTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SingleTableInheritanceTest.java
index ab45130c1..2e8c25c42 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SingleTableInheritanceTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SingleTableInheritanceTest.java
@@ -154,7 +154,7 @@ public void testQueryUpdate(VertxTestContext context) {
.thenCompose( s -> s.persist( spells ).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
.thenCompose( s -> s
- .createQuery( "update Book set title=title||' II' where title='Necronomicon'" )
+ .createMutationQuery( "update Book set title=title||' II' where title='Necronomicon'" )
.executeUpdate() )
.thenCompose( v -> openSession() )
.thenCompose( s -> s.find( Book.class, 6 ) )
@@ -164,7 +164,7 @@ public void testQueryUpdate(VertxTestContext context) {
assertEquals( book.getTitle(), "Necronomicon II" );
} )
.thenCompose( v -> openSession() ).thenCompose( s -> s
- .createQuery( "delete Book where title='Necronomicon II'" )
+ .createMutationQuery( "delete Book where title='Necronomicon II'" )
.executeUpdate() )
.thenCompose( v -> openSession() )
.thenCompose( s -> s.find( Book.class, 6 ) )
@@ -179,7 +179,7 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
test( context, openSession()
.thenCompose( s -> s.persist( spells ).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "update Book set title=title||:sfx where title=:tit" )
+ .thenCompose( s -> s.createMutationQuery( "update Book set title=title||:sfx where title=:tit" )
.setParameter( "sfx", " II" )
.setParameter( "tit", "Necronomicon" )
.executeUpdate() )
@@ -191,7 +191,7 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
assertEquals( book.getTitle(), "Necronomicon II" );
} )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "delete Book where title=:tit" )
+ .thenCompose( s -> s.createMutationQuery( "delete Book where title=:tit" )
.setParameter( "tit", "Necronomicon II" )
.executeUpdate() )
.thenCompose( v -> openSession() )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/StatisticsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/StatisticsTest.java
index a988b7576..7d398336e 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/StatisticsTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/StatisticsTest.java
@@ -72,7 +72,7 @@ public void testMutinyStatistics(VertxTestContext context) {
assertEquals( 0, statistics.getQueries().length );
} )
.chain( () -> getMutinySessionFactory()
- .withTransaction( s -> s.createQuery( "from Named" ).getResultList() ) )
+ .withTransaction( s -> s.createSelectionQuery( "from Named", Named.class ).getResultList() ) )
.invoke( v -> {
assertEquals( 3L, statistics.getEntityInsertCount() );
assertEquals( 3L, statistics.getEntityLoadCount() );
@@ -127,7 +127,7 @@ public void testStageStatistics(VertxTestContext context) {
} )
.thenCompose( v -> getSessionFactory()
.withTransaction( s -> s
- .createQuery( "from Named" ).getResultList() ) )
+ .createSelectionQuery( "from Named", Named.class ).getResultList() ) )
.thenAccept( v -> {
assertEquals( 3L, statistics.getEntityInsertCount() );
assertEquals( 3L, statistics.getEntityLoadCount() );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectElementCollectionForEmbeddableTypeListTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectElementCollectionForEmbeddableTypeListTest.java
index 8a7ec93a8..15f6c3958 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectElementCollectionForEmbeddableTypeListTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectElementCollectionForEmbeddableTypeListTest.java
@@ -111,7 +111,7 @@ public void joinFetch(VertxTestContext context) {
test (
context,
getMutinySessionFactory()
- .withTransaction( session -> session.createQuery("select distinct p from Person p join fetch p.phones where p.name='Claude'", Person.class)
+ .withTransaction( session -> session.createSelectionQuery("select distinct p from Person p join fetch p.phones where p.name='Claude'", Person.class)
.getResultList()
.invoke( all -> assertEquals( 2, all.size() ) )
.invoke( all -> all.forEach( result -> {
@@ -127,7 +127,7 @@ public void noJoinFetch(VertxTestContext context) {
test (
context,
getMutinySessionFactory()
- .withTransaction( session -> session.createQuery("from Person p where p.name='Claude'", Person.class)
+ .withTransaction( session -> session.createSelectionQuery("from Person p where p.name='Claude'", Person.class)
.getResultList()
.invoke( all -> assertEquals( 2, all.size() ) )
.invoke( all -> all.forEach( result -> assertFalse( Hibernate.isInitialized( result.phones ) ) ) )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectFetchTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectFetchTest.java
index ecb87b930..21de969b9 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectFetchTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/SubselectFetchTest.java
@@ -53,8 +53,8 @@ protected Collection> annotatedEntities() {
@AfterEach
public void cleanDb(VertxTestContext context) {
test( context, getSessionFactory()
- .withTransaction( s -> s.createQuery( "delete from Element" ).executeUpdate()
- .thenCompose( v -> s.createQuery( "delete from Node" ).executeUpdate() ) ) );
+ .withTransaction( s -> s.createMutationQuery( "delete from Element" ).executeUpdate()
+ .thenCompose( v -> s.createMutationQuery( "delete from Node" ).executeUpdate() ) ) );
}
@Test
@@ -70,7 +70,7 @@ public void testQuery(VertxTestContext context) {
test( context, getSessionFactory()
.withTransaction( s -> s.persist( basik ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.createQuery( "from Node n order by id", Node.class )
+ .thenCompose( s -> s.createSelectionQuery( "from Node n order by id", Node.class )
.getResultList()
.thenCompose( list -> {
assertEquals( list.size(), 2 );
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UTCTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UTCTest.java
index 62b3be6be..6cf610cb7 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UTCTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UTCTest.java
@@ -141,7 +141,7 @@ private void testField(VertxTestContext context, String columnName, Function getMutinySessionFactory()
.withSession( session -> session
- .createQuery( "from ThingInUTC where " + columnName + "=:dt", Thing.class )
+ .createSelectionQuery( "from ThingInUTC where " + columnName + "=:dt", Thing.class )
.setParameter( "dt", fieldValue.apply( thing ) )
.getSingleResultOrNull() )
.invoke( result -> {
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnicodeCharsTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnicodeCharsTest.java
index e98aa63da..2098a5fa9 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnicodeCharsTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnicodeCharsTest.java
@@ -55,7 +55,7 @@ public void testStringTypeWithUnicode(VertxTestContext context) {
test( context, getSessionFactory()
.withTransaction( s -> s.persist( original ) )
.thenCompose( v -> getSessionFactory().withSession( s -> s
- .createQuery( "select unicodeString from UnicodeString" ).getSingleResultOrNull() ) )
+ .createSelectionQuery( "select unicodeString from UnicodeString", String.class ).getSingleResultOrNull() ) )
.thenAccept( found -> assertEquals( expected, found ) )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnionSubclassInheritanceTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnionSubclassInheritanceTest.java
index b5996fdba..4a78b51eb 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnionSubclassInheritanceTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UnionSubclassInheritanceTest.java
@@ -135,11 +135,11 @@ public void testQueryUpdate(VertxTestContext context) {
openSession()
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
.thenCompose( v -> openSession() )
.thenCompose( s -> s.find(Book.class, 6))
.thenAccept( book -> {
@@ -148,7 +148,7 @@ public void testQueryUpdate(VertxTestContext context) {
assertEquals(book.getTitle(), "Necronomicon II");
} )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
.thenCompose( v -> openSession() )
.thenCompose(s -> s.find(Book.class, 6))
.thenAccept( Assertions::assertNull )
@@ -164,12 +164,12 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
openSession()
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update SpellBook set forbidden=:fob where title=:tit")
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=:fob where title=:tit")
.setParameter("fob", false)
.setParameter("tit", "Necronomicon")
.executeUpdate() ) )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("update Book set title=title||:sfx where title=:tit")
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||:sfx where title=:tit")
.setParameter("sfx", " II")
.setParameter("tit", "Necronomicon")
.executeUpdate() ) )
@@ -181,7 +181,7 @@ public void testQueryUpdateWithParameters(VertxTestContext context) {
assertEquals(book.getTitle(), "Necronomicon II");
} )
.thenCompose( v -> openSession() )
- .thenCompose( s -> s.withTransaction( t -> s.createQuery("delete Book where title=:tit")
+ .thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title=:tit")
.setParameter("tit", "Necronomicon II")
.executeUpdate() ) )
.thenCompose( v -> openSession() )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UpsertTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UpsertTest.java
index 94c94f55c..3ba93cbac 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UpsertTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/UpsertTest.java
@@ -57,7 +57,7 @@ public void testMutinyUpsert(VertxTestContext context) {
.call( () -> ss.upsert( new Record( 456L, "hello mars" ) ) )
)
.call( v -> getMutinySessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.invoke( results -> assertThat( results ).containsExactly(
new Record( 123L, "hello earth" ),
new Record( 456L, "hello mars" )
@@ -67,7 +67,7 @@ public void testMutinyUpsert(VertxTestContext context) {
.upsert( new Record( 123L, "goodbye earth" ) )
) )
.call( v -> getMutinySessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.invoke( results -> assertThat( results ).containsExactly(
new Record( 123L, "goodbye earth" ),
new Record( 456L, "hello mars" )
@@ -83,7 +83,7 @@ public void testMutinyUpsertWithEntityName(VertxTestContext context) {
.call( () -> ss.upsert( Record.class.getName(), new Record( 456L, "hello mars" ) ) )
)
.call( v -> getMutinySessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.invoke( results -> assertThat( results ).containsExactly(
new Record( 123L, "hello earth" ),
new Record( 456L, "hello mars" )
@@ -93,7 +93,7 @@ public void testMutinyUpsertWithEntityName(VertxTestContext context) {
.upsert( Record.class.getName(), new Record( 123L, "goodbye earth" ) )
) )
.call( v -> getMutinySessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.invoke( results -> assertThat( results ).containsExactly(
new Record( 123L, "goodbye earth" ),
new Record( 456L, "hello mars" )
@@ -109,7 +109,7 @@ public void testStageUpsert(VertxTestContext context) {
.thenCompose( v -> ss.upsert( new Record( 456L, "hello mars" ) ) )
)
.thenCompose( v -> getSessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.thenAccept( results -> assertThat( results ).containsExactly(
new Record( 123L, "hello earth" ),
new Record( 456L, "hello mars" )
@@ -119,7 +119,7 @@ public void testStageUpsert(VertxTestContext context) {
.upsert( new Record( 123L, "goodbye earth" ) )
) )
.thenCompose( v -> getSessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.thenAccept( results -> assertThat( results ).containsExactly(
new Record( 123L, "goodbye earth" ),
new Record( 456L, "hello mars" )
@@ -135,7 +135,7 @@ public void testStageUpsertWithEntityName(VertxTestContext context) {
.thenCompose( v -> ss.upsert( Record.class.getName(), new Record( 456L, "hello mars" ) ) )
)
.thenCompose( v -> getSessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.thenAccept( results -> assertThat( results ).containsExactly(
new Record( 123L, "hello earth" ),
new Record( 456L, "hello mars" )
@@ -145,7 +145,7 @@ public void testStageUpsertWithEntityName(VertxTestContext context) {
.upsert( Record.class.getName(), new Record( 123L, "goodbye earth" ) )
) )
.thenCompose( v -> getSessionFactory().withStatelessTransaction( ss -> ss
- .createQuery( "from Record order by id", Record.class ).getResultList() )
+ .createSelectionQuery( "from Record order by id", Record.class ).getResultList() )
.thenAccept( results -> assertThat( results ).containsExactly(
new Record( 123L, "goodbye earth" ),
new Record( 456L, "hello mars" )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/dynamic/DynamicEntityTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/dynamic/DynamicEntityTest.java
index c87a13a73..bbdad20cc 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/dynamic/DynamicEntityTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/dynamic/DynamicEntityTest.java
@@ -43,7 +43,7 @@ public void test(VertxTestContext context) {
getMutinySessionFactory()
.withTransaction( session -> session.persist( book ) )
.chain( v -> getMutinySessionFactory()
- .withSession( session -> session.createQuery( "from Book", Map.class ).getSingleResult() )
+ .withSession( session -> session.createSelectionQuery( "from Book", Map.class ).getSingleResult() )
.invoke( map -> assertEquals( "Christian Bauer and Gavin King", map.get( "author" ) ) ) )
);
}
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/issue/JoinedSubclassInheritanceWithManyToOneTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/issue/JoinedSubclassInheritanceWithManyToOneTest.java
index 215377820..56b7705c8 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/issue/JoinedSubclassInheritanceWithManyToOneTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/issue/JoinedSubclassInheritanceWithManyToOneTest.java
@@ -53,7 +53,7 @@ public void testSubclassListAll(VertxTestContext context) {
.withTransaction( session -> session.persistAll( clothingItem, itemInstance ) )
.chain( () -> getMutinySessionFactory()
.withSession( session -> session
- .createQuery( "from ItemInstance", ItemInstance.class ).getResultList()
+ .createSelectionQuery( "from ItemInstance", ItemInstance.class ).getResultList()
.invoke( list -> assertThat( list ).hasSize( 1 )
.satisfies( entry -> assertThat( entry )
.isInstanceOf( ClothingItemInstance.class )
diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java
index 3f73d94b1..7c9a02730 100644
--- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java
+++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/JsonTypeTest.java
@@ -56,7 +56,7 @@ protected Collection> annotatedEntities() {
public CompletionStage deleteEntities(Class>... entities) {
return getSessionFactory()
.withTransaction( s -> loop( entities, entityClass -> s
- .createQuery( "from JsonEntity", entityClass )
+ .createSelectionQuery( "from JsonEntity", entityClass )
.getResultList()
.thenCompose( list -> loop( list, entity -> s.remove( entity ) ) ) ) );
}