fix signature of Query.setOrder()
This commit is contained in:
parent
538cad670f
commit
9d30d210ed
|
@ -413,7 +413,7 @@ public class ProcedureCallImpl<R>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query<R> setOrder(List<Order<? super R>> orderList) {
|
public Query<R> setOrder(List<? extends Order<? super R>> orderList) {
|
||||||
throw new UnsupportedOperationException("Ordering not supported for stored procedure calls");
|
throw new UnsupportedOperationException("Ordering not supported for stored procedure calls");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -922,7 +922,7 @@ public interface Query<R> extends SelectionQuery<R>, MutationQuery, TypedQuery<R
|
||||||
Query<R> setLockMode(LockModeType lockMode);
|
Query<R> setLockMode(LockModeType lockMode);
|
||||||
|
|
||||||
@Override @Incubating
|
@Override @Incubating
|
||||||
Query<R> setOrder(List<Order<? super R>> orderList);
|
Query<R> setOrder(List<? extends Order<? super R>> orderList);
|
||||||
|
|
||||||
@Override @Incubating
|
@Override @Incubating
|
||||||
Query<R> setOrder(Order<? super R> order);
|
Query<R> setOrder(Order<? super R> order);
|
||||||
|
|
|
@ -590,7 +590,7 @@ public interface SelectionQuery<R> extends CommonQueryContract {
|
||||||
* @since 6.3
|
* @since 6.3
|
||||||
*/
|
*/
|
||||||
@Incubating
|
@Incubating
|
||||||
SelectionQuery<R> setOrder(List<Order<? super R>> orderList);
|
SelectionQuery<R> setOrder(List<? extends Order<? super R>> orderList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the result type of this query is an entity class, add a
|
* If the result type of this query is an entity class, add a
|
||||||
|
|
|
@ -295,7 +295,7 @@ public abstract class AbstractQuery<R>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query<R> setOrder(List<Order<? super R>> orders) {
|
public Query<R> setOrder(List<? extends Order<? super R>> orders) {
|
||||||
throw new UnsupportedOperationException( "Should be implemented by " + this.getClass().getName() );
|
throw new UnsupportedOperationException( "Should be implemented by " + this.getClass().getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1581,7 +1581,7 @@ public class NativeQueryImpl<R>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query<R> setOrder(List<Order<? super R>> orderList) {
|
public Query<R> setOrder(List<? extends Order<? super R>> orderList) {
|
||||||
throw new UnsupportedOperationException("Ordering not currently supported for native queries");
|
throw new UnsupportedOperationException("Ordering not currently supported for native queries");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,29 +122,26 @@ abstract class AbstractSqmSelectionQuery<R> extends AbstractSelectionQuery<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SelectionQuery<R> setOrder(List<Order<? super R>> orderList) {
|
public SelectionQuery<R> setOrder(List<? extends Order<? super R>> orderList) {
|
||||||
SqmSelectStatement<R> sqm = getSqmSelectStatement();
|
final SqmSelectStatement<R> selectStatement = getSqmSelectStatement().copy( noParamCopyContext() );
|
||||||
sqm = sqm.copy( noParamCopyContext() );
|
selectStatement.orderBy( orderList.stream().map( order -> sortSpecification( selectStatement, order ) )
|
||||||
final SqmSelectStatement<R> select = sqm;
|
|
||||||
sqm.orderBy( orderList.stream().map( order -> sortSpecification( select, order ) )
|
|
||||||
.collect( toList() ) );
|
.collect( toList() ) );
|
||||||
// TODO: when the QueryInterpretationCache can handle caching criteria queries,
|
// TODO: when the QueryInterpretationCache can handle caching criteria queries,
|
||||||
// simply cache the new SQM as if it were a criteria query, and remove this:
|
// simply cache the new SQM as if it were a criteria query, and remove this:
|
||||||
getQueryOptions().setQueryPlanCachingEnabled( false );
|
getQueryOptions().setQueryPlanCachingEnabled( false );
|
||||||
setSqmStatement( sqm );
|
setSqmStatement( selectStatement );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SelectionQuery<R> setOrder(Order<? super R> order) {
|
public SelectionQuery<R> setOrder(Order<? super R> order) {
|
||||||
SqmSelectStatement<R> sqm = getSqmSelectStatement();
|
final SqmSelectStatement<R> selectStatement = getSqmSelectStatement().copy( noParamCopyContext() );
|
||||||
sqm = sqm.copy( noParamCopyContext() );
|
selectStatement.orderBy( sortSpecification( selectStatement, order ) );
|
||||||
sqm.orderBy( sortSpecification( sqm, order ) );
|
|
||||||
// TODO: when the QueryInterpretationCache can handle caching criteria queries,
|
// TODO: when the QueryInterpretationCache can handle caching criteria queries,
|
||||||
// simply cache the new SQM as if it were a criteria query, and remove this:
|
// simply cache the new SQM as if it were a criteria query, and remove this:
|
||||||
getQueryOptions().setQueryPlanCachingEnabled( false );
|
getQueryOptions().setQueryPlanCachingEnabled( false );
|
||||||
setSqmStatement( sqm );
|
setSqmStatement( selectStatement );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -758,7 +758,7 @@ public class QuerySqmImpl<R>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query<R> setOrder(List<Order<? super R>> orders) {
|
public Query<R> setOrder(List<? extends Order<? super R>> orders) {
|
||||||
super.setOrder(orders);
|
super.setOrder(orders);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ public abstract class DelegatingSqmSelectionQueryImplementor<R> implements SqmSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Incubating
|
@Incubating
|
||||||
public SqmSelectionQueryImplementor<R> setOrder(List<Order<? super R>> orders) {
|
public SqmSelectionQueryImplementor<R> setOrder(List<? extends Order<? super R>> orders) {
|
||||||
getDelegate().setOrder( orders );
|
getDelegate().setOrder( orders );
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.hibernate.orm.test.jpa.ejb3configuration;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -216,6 +217,13 @@ public class ConfigurationObjectSettingTest {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyToProperties(Properties properties, Object... pairs) {
|
||||||
|
assert pairs.length % 2 == 0;
|
||||||
|
for ( int i = 0; i < pairs.length; i+=2 ) {
|
||||||
|
properties.put( pairs[i], pairs[i+1] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyJdbcSettings(String jdbcUrl, String jdbcDriver, String jdbcUser, String jdbcPassword) {
|
private void verifyJdbcSettings(String jdbcUrl, String jdbcDriver, String jdbcUser, String jdbcPassword) {
|
||||||
final String urlValue = "some:url";
|
final String urlValue = "some:url";
|
||||||
final String driverValue = "some.jdbc.Driver";
|
final String driverValue = "some.jdbc.Driver";
|
||||||
|
@ -228,7 +236,7 @@ public class ConfigurationObjectSettingTest {
|
||||||
{
|
{
|
||||||
builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(
|
builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(
|
||||||
empty,
|
empty,
|
||||||
CollectionHelper.toMap(
|
Map.of(
|
||||||
jdbcUrl, urlValue,
|
jdbcUrl, urlValue,
|
||||||
jdbcDriver, driverValue,
|
jdbcDriver, driverValue,
|
||||||
jdbcUser, userValue,
|
jdbcUser, userValue,
|
||||||
|
@ -246,7 +254,7 @@ public class ConfigurationObjectSettingTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUnitInfoAdapter pui = new PersistenceUnitInfoAdapter();
|
PersistenceUnitInfoAdapter pui = new PersistenceUnitInfoAdapter();
|
||||||
CollectionHelper.applyToProperties(
|
applyToProperties(
|
||||||
pui.getProperties(),
|
pui.getProperties(),
|
||||||
jdbcUrl, urlValue,
|
jdbcUrl, urlValue,
|
||||||
jdbcDriver, driverValue,
|
jdbcDriver, driverValue,
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
|
||||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||||
import org.hibernate.tool.schema.Action;
|
import org.hibernate.tool.schema.Action;
|
||||||
|
@ -137,6 +136,13 @@ public class JakartaSchemaToolingTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void applyToProperties(Properties properties, Object... pairs) {
|
||||||
|
assert pairs.length % 2 == 0;
|
||||||
|
for ( int i = 0; i < pairs.length; i+=2 ) {
|
||||||
|
properties.put( pairs[i], pairs[i+1] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private SessionFactoryImplementor buildSessionFactory(Object... settingPairs) {
|
private SessionFactoryImplementor buildSessionFactory(Object... settingPairs) {
|
||||||
final Properties settings = new Properties();
|
final Properties settings = new Properties();
|
||||||
settings.setProperty( AvailableSettings.AUTOCOMMIT, "false" );
|
settings.setProperty( AvailableSettings.AUTOCOMMIT, "false" );
|
||||||
|
@ -146,7 +152,7 @@ public class JakartaSchemaToolingTests {
|
||||||
DriverManagerConnectionProviderImpl.INIT_SQL,
|
DriverManagerConnectionProviderImpl.INIT_SQL,
|
||||||
Environment.getProperties().getProperty( DriverManagerConnectionProviderImpl.INIT_SQL )
|
Environment.getProperties().getProperty( DriverManagerConnectionProviderImpl.INIT_SQL )
|
||||||
);
|
);
|
||||||
CollectionHelper.applyToProperties( settings, settingPairs );
|
applyToProperties( settings, settingPairs );
|
||||||
ServiceRegistryUtil.applySettings( settings );
|
ServiceRegistryUtil.applySettings( settings );
|
||||||
|
|
||||||
final PersistenceUnitDescriptorAdapter puDescriptor = new PersistenceUnitDescriptorAdapter() {
|
final PersistenceUnitDescriptorAdapter puDescriptor = new PersistenceUnitDescriptorAdapter() {
|
||||||
|
|
|
@ -6,13 +6,13 @@ package org.hibernate.orm.test.mapping.fetch.depth;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import jakarta.persistence.EntityManagerFactory;
|
import jakarta.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
|
||||||
import org.hibernate.tool.schema.Action;
|
import org.hibernate.tool.schema.Action;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.JiraKey;
|
import org.hibernate.testing.orm.junit.JiraKey;
|
||||||
|
@ -85,12 +85,12 @@ public class NoDepthTests {
|
||||||
par.addAsResource( "units/many2many/fetch-depth.xml", "META-INF/persistence.xml" );
|
par.addAsResource( "units/many2many/fetch-depth.xml", "META-INF/persistence.xml" );
|
||||||
|
|
||||||
try ( final ShrinkWrapClassLoader classLoader = new ShrinkWrapClassLoader( par ) ) {
|
try ( final ShrinkWrapClassLoader classLoader = new ShrinkWrapClassLoader( par ) ) {
|
||||||
final Map<String, ?> settings = CollectionHelper.toMap(
|
final Map<String, Object> settings = new HashMap<>( Map.of(
|
||||||
CLASSLOADERS, Arrays.asList( classLoader, getClass().getClassLoader() ),
|
CLASSLOADERS, Arrays.asList( classLoader, getClass().getClassLoader() ),
|
||||||
MAX_FETCH_DEPTH, configureMax ? "10" : "",
|
MAX_FETCH_DEPTH, configureMax ? "10" : "",
|
||||||
HBM2DDL_AUTO, Action.CREATE_DROP,
|
HBM2DDL_AUTO, Action.CREATE_DROP,
|
||||||
FORMAT_SQL, "true"
|
FORMAT_SQL, "true"
|
||||||
);
|
) );
|
||||||
ServiceRegistryUtil.applySettings( settings );
|
ServiceRegistryUtil.applySettings( settings );
|
||||||
|
|
||||||
final EntityManagerFactory emf = createEntityManagerFactory( "fetch-depth", settings );
|
final EntityManagerFactory emf = createEntityManagerFactory( "fetch-depth", settings );
|
||||||
|
|
|
@ -6,28 +6,25 @@ package org.hibernate.orm.test.mapping.mutability.converted;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
|
||||||
import jakarta.persistence.AttributeConverter;
|
import jakarta.persistence.AttributeConverter;
|
||||||
|
|
||||||
|
import static org.hibernate.internal.util.StringHelper.isEmpty;
|
||||||
|
import static org.hibernate.internal.util.StringHelper.join;
|
||||||
|
import static org.hibernate.internal.util.StringHelper.split;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class MapConverter implements AttributeConverter<Map<String, String>, String> {
|
public class MapConverter implements AttributeConverter<Map<String, String>, String> {
|
||||||
@Override
|
@Override
|
||||||
public String convertToDatabaseColumn(Map<String, String> map) {
|
public String convertToDatabaseColumn(Map<String, String> map) {
|
||||||
if ( CollectionHelper.isEmpty( map ) ) {
|
return CollectionHelper.isEmpty( map ) ? null : join( ", ", CollectionHelper.asPairs( map ) );
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return StringHelper.join( ", ", CollectionHelper.asPairs( map ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> convertToEntityAttribute(String pairs) {
|
public Map<String, String> convertToEntityAttribute(String pairs) {
|
||||||
if ( StringHelper.isEmpty( pairs ) ) {
|
return isEmpty( pairs ) ? null : CollectionHelper.toMap( split( ", ", pairs ) );
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return CollectionHelper.toMap( StringHelper.split( ", ", pairs ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.toSettingsMap;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
@ -60,14 +59,8 @@ public class WhereFragmentTests {
|
||||||
* Loads a User, fetching their detail and skills using an entity-graph
|
* Loads a User, fetching their detail and skills using an entity-graph
|
||||||
*/
|
*/
|
||||||
public User findUserByIdUsingEntityGraph(Integer id, SessionFactoryScope factoryScope) {
|
public User findUserByIdUsingEntityGraph(Integer id, SessionFactoryScope factoryScope) {
|
||||||
return factoryScope.fromTransaction( (session) -> {
|
return factoryScope.fromTransaction( (session) -> session.find( User.class, id,
|
||||||
final Map<String, Object> properties = toSettingsMap(
|
Map.of( SpecHints.HINT_SPEC_FETCH_GRAPH, session.getEntityGraph("user-entity-graph") ) ) );
|
||||||
SpecHints.HINT_SPEC_FETCH_GRAPH,
|
|
||||||
session.getEntityGraph("user-entity-graph")
|
|
||||||
);
|
|
||||||
|
|
||||||
return session.find(User.class, id, properties);
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,6 @@ package org.hibernate.orm.test.query.hql;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -25,8 +24,8 @@ import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.toMap;
|
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +56,11 @@ public class LegacyParameterTests {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
(s) -> {
|
(s) -> {
|
||||||
Map<String,String> parameters = toMap( "nickName", null );
|
|
||||||
|
|
||||||
Query<Human> q = s.createQuery(
|
Query<Human> q = s.createQuery(
|
||||||
"from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)",
|
"from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)",
|
||||||
Human.class
|
Human.class
|
||||||
);
|
);
|
||||||
q.setProperties( (parameters) );
|
q.setProperties( singletonMap( "nickName", null ) );
|
||||||
assertThat( q.list().size(), is( 0 ) );
|
assertThat( q.list().size(), is( 0 ) );
|
||||||
|
|
||||||
Human human1 = new Human();
|
Human human1 = new Human();
|
||||||
|
@ -71,20 +68,14 @@ public class LegacyParameterTests {
|
||||||
human1.setNickName( null );
|
human1.setNickName( null );
|
||||||
s.persist( human1 );
|
s.persist( human1 );
|
||||||
|
|
||||||
parameters = new HashMap<>();
|
|
||||||
|
|
||||||
parameters.put( "nickName", null );
|
|
||||||
q = s.createQuery( "from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)", Human.class );
|
q = s.createQuery( "from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)", Human.class );
|
||||||
q.setProperties( (parameters) );
|
q.setProperties( singletonMap( "nickName", null ) );
|
||||||
assertThat( q.list().size(), is( 1 ) );
|
assertThat( q.list().size(), is( 1 ) );
|
||||||
Human found = q.list().get( 0 );
|
Human found = q.list().get( 0 );
|
||||||
assertThat( found.getId(), is( human1.getId() ) );
|
assertThat( found.getId(), is( human1.getId() ) );
|
||||||
|
|
||||||
parameters = new HashMap<>();
|
|
||||||
parameters.put( "nickName", "nick" );
|
|
||||||
|
|
||||||
q = s.createQuery( "from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)", Human.class );
|
q = s.createQuery( "from Human h where h.nickName = :nickName or (h.nickName is null and :nickName is null)", Human.class );
|
||||||
q.setProperties( (parameters) );
|
q.setProperties( singletonMap( "nickName", "nick" ) );
|
||||||
assertThat( q.list().size(), is( 1 ) );
|
assertThat( q.list().size(), is( 1 ) );
|
||||||
found = q.list().get( 0 );
|
found = q.list().get( 0 );
|
||||||
assertThat( found.getId(), is( 1L ) );
|
assertThat( found.getId(), is( 1L ) );
|
||||||
|
@ -97,8 +88,6 @@ public class LegacyParameterTests {
|
||||||
public void testSetPropertiesMapNotContainingAllTheParameters(SessionFactoryScope scope) {
|
public void testSetPropertiesMapNotContainingAllTheParameters(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
(s) -> {
|
(s) -> {
|
||||||
Map<String,String> parameters = toMap( "nickNames", "nick" );
|
|
||||||
|
|
||||||
List<Integer> intValues = new ArrayList<>();
|
List<Integer> intValues = new ArrayList<>();
|
||||||
intValues.add( 1 );
|
intValues.add( 1 );
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
|
@ -106,7 +95,7 @@ public class LegacyParameterTests {
|
||||||
"from Human h where h.nickName in (:nickNames) and h.intValue in (:intValues)"
|
"from Human h where h.nickName in (:nickNames) and h.intValue in (:intValues)"
|
||||||
);
|
);
|
||||||
q.setParameterList( "intValues" , intValues);
|
q.setParameterList( "intValues" , intValues);
|
||||||
q.setProperties( (parameters) );
|
q.setProperties( Map.of( "nickNames", "nick" ) );
|
||||||
assertThat( q.list().size(), is( 1 ) );
|
assertThat( q.list().size(), is( 1 ) );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -40,7 +40,6 @@ import jakarta.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION;
|
import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION;
|
||||||
import static org.hibernate.internal.util.collections.CollectionHelper.toMap;
|
|
||||||
import static org.hibernate.jpa.HibernateHints.HINT_TENANT_ID;
|
import static org.hibernate.jpa.HibernateHints.HINT_TENANT_ID;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
@ -50,6 +49,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@DomainModel(annotatedClasses = { Account.class, Client.class, Record.class })
|
@DomainModel(annotatedClasses = { Account.class, Client.class, Record.class })
|
||||||
|
@ -254,7 +254,7 @@ public class TenantIdTest implements SessionFactoryProducer {
|
||||||
|
|
||||||
currentTenant = null;
|
currentTenant = null;
|
||||||
final EntityManagerFactory emf = scope.getSessionFactory();
|
final EntityManagerFactory emf = scope.getSessionFactory();
|
||||||
try (EntityManager em = emf.createEntityManager( toMap( HINT_TENANT_ID, "mine" ) ) ) {
|
try (EntityManager em = emf.createEntityManager( Map.of( HINT_TENANT_ID, "mine" ) ) ) {
|
||||||
Record r = em.find( Record.class, record.id );
|
Record r = em.find( Record.class, record.id );
|
||||||
assertEquals( "mine", r.state.tenantId );
|
assertEquals( "mine", r.state.tenantId );
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,13 @@ public class ServiceRegistryUtil {
|
||||||
|
|
||||||
public static void applySettings(Map<?, ?> properties) {
|
public static void applySettings(Map<?, ?> properties) {
|
||||||
if ( !properties.containsKey( AvailableSettings.CONNECTION_PROVIDER ) ) {
|
if ( !properties.containsKey( AvailableSettings.CONNECTION_PROVIDER ) ) {
|
||||||
//noinspection unchecked
|
@SuppressWarnings( "unchecked" )
|
||||||
( (Map<Object, Object>) properties ).put(
|
final Map<Object, Object> objectMap = (Map<Object, Object>) properties;
|
||||||
|
objectMap.put(
|
||||||
AvailableSettings.CONNECTION_PROVIDER,
|
AvailableSettings.CONNECTION_PROVIDER,
|
||||||
SharedDriverManagerConnectionProviderImpl.getInstance()
|
SharedDriverManagerConnectionProviderImpl.getInstance()
|
||||||
);
|
);
|
||||||
( (Map<Object, Object>) properties ).put(
|
objectMap.put(
|
||||||
AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT,
|
AvailableSettings.CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT,
|
||||||
Boolean.TRUE
|
Boolean.TRUE
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue