Merge remote-tracking branch 'upstream/master' into wip/6.0

This commit is contained in:
Christian Beikov 2021-02-12 15:49:53 +01:00
commit 35643c468a
84 changed files with 402 additions and 985 deletions

View File

@ -7,7 +7,7 @@ mysql_5_7() {
mysql_8_0() {
docker rm -f mysql || true
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:8.0.21 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mysql:8.0.21 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
}
mariadb() {
@ -25,6 +25,11 @@ postgresql_13() {
docker run --name postgres -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d postgres:13.0
}
postgis(){
docker rm -f postgis || true
docker run --name postgis -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d postgis/postgis:11-2.5
}
db2() {
docker rm -f db2 || true
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ibmcom/db2:11.5.5.0
@ -38,6 +43,65 @@ db2() {
docker exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile && /database/config/orm_test/sqllib/bin/db2 'connect to orm_test' && /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
}
db2_spatial() {
docker rm -f db2spatial || true
temp_dir=$(mktemp -d)
cat <<EOF >${temp_dir}/ewkt.sql
create or replace function db2gse.asewkt(geometry db2gse.st_geometry)
returns clob(2G)
specific db2gse.asewkt1
language sql
deterministic
no external action
reads sql data
return 'srid=' || varchar(db2gse.st_srsid(geometry)) || ';' || db2gse.st_astext(geometry)
;
-- Create SQL function to create a geometry from EWKT format
create or replace function db2gse.geomfromewkt(instring varchar(32000))
returns db2gse.st_geometry
specific db2gse.fromewkt1
language sql
deterministic
no external action
reads sql data
return db2gse.st_geometry(
substr(instring,posstr(instring,';')+1, length(instring) - posstr(instring,';')),
integer(substr(instring,posstr(instring,'=')+1,posstr(instring,';')-(posstr(instring,'=')+1)))
)
;
-- Create a DB2 transform group to return and accept EWKT
CREATE TRANSFORM FOR db2gse.ST_Geometry EWKT (
FROM SQL WITH FUNCTION db2gse.asewkt(db2gse.ST_Geometry),
TO SQL WITH FUNCTION db2gse.geomfromewkt(varchar(32000)) )
;
-- Redefine the default DB2_PROGRAM to return and accept EWKT instead of WKT
DROP TRANSFORM DB2_PROGRAM FOR db2gse.ST_Geometry;
CREATE TRANSFORM FOR db2gse.ST_Geometry DB2_PROGRAM (
FROM SQL WITH FUNCTION db2gse.asewkt(db2gse.ST_Geometry),
TO SQL WITH FUNCTION db2gse.geomfromewkt(varchar(32000)) )
;
EOF
docker run --name db2spatial --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false \
-v ${temp_dir}:/conf \
-p 50000:50000 -d ibmcom/db2:11.5.5.0
# Give the container some time to start
OUTPUT=
while [[ $OUTPUT != *"Setup has completed."* ]]; do
echo "Waiting for DB2 to start..."
sleep 10
OUTPUT=$(docker logs db2spatial)
done
sleep 10
echo "Enabling spatial extender"
docker exec -t db2spatial su - orm_test bash -c "/database/config/orm_test/sqllib/db2profile && /database/config/orm_test/sqllib/bin/db2se enable_db orm_test"
echo "Installing required transform group"
docker exec -t db2spatial su - orm_test bash -c "/database/config/orm_test/sqllib/db2profile && /database/config/orm_test/sqllib/bin/db2 'connect to orm_test' && /database/config/orm_test/sqllib/bin/db2 -tvf /conf/ewkt.sql"
}
mssql() {
docker rm -f mssql || true
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=Hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
@ -156,6 +220,19 @@ hana() {
echo "HANA successfully started"
}
cockroachdb() {
docker rm -f cockroach || true
docker run -d --name=cockroach -p 26257:26257 -p 8080:8080 cockroachdb/cockroach:v20.2.4 start-single-node --insecure
OUTPUT=
while [[ $OUTPUT != *"CockroachDB node starting"* ]]; do
echo "Waiting for CockroachDB to start..."
sleep 10
OUTPUT=$(docker logs cockroach)
done
echo "Cockroachdb successfully started"
}
if [ -z ${1} ]; then
echo "No db name provided"
echo "Provide one of:"
@ -167,6 +244,10 @@ if [ -z ${1} ]; then
echo -e "\tdb2"
echo -e "\tmssql"
echo -e "\toracle"
echo -e "\tpostgis"
echo -e "\tdb2_spatial"
echo -e "\thana"
echo -e "\tcockroachdb"
else
${1}
fi

View File

@ -78,6 +78,14 @@ ext {
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:mysql://127.0.0.1/hibernate_orm_test?useSSL=false'
],
// uses docker mysql_8_0
mysql8_spatial_ci: [
'db.dialect' : 'org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect',
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true&useSSL=false'
],
mariadb : [
'db.dialect' : 'org.hibernate.dialect.MariaDBDialect',
'jdbc.driver': 'org.mariadb.jdbc.Driver',
@ -122,6 +130,13 @@ ext {
'jdbc.pass' : 'Oracle18',
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521:XE'
],
oracle_spatial_ci : [
'db.dialect' : 'org.hibernate.spatial.dialect.oracle.OracleSpatial10gDialect',
'jdbc.driver': 'oracle.jdbc.OracleDriver',
'jdbc.user' : 'SYSTEM',
'jdbc.pass' : 'Oracle18',
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521:XE'
],
mssql : [
'db.dialect' : 'org.hibernate.dialect.SQLServerDialect',
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
@ -136,6 +151,13 @@ ext {
'jdbc.pass' : 'Hibernate_orm_test',
'jdbc.url' : 'jdbc:sqlserver://' + dbHost + ';databaseName=hibernate_orm_test'
],
mssql_spatial_ci : [
'db.dialect' : 'org.hibernate.spatial.dialect.sqlserver.SqlServer2012SpatialDialect',
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'jdbc.user' : 'sa',
'jdbc.pass' : 'Hibernate_orm_test',
'jdbc.url' : 'jdbc:sqlserver://' + dbHost + ';databaseName=hibernate_orm_test'
],
informix : [
'db.dialect' : 'org.hibernate.dialect.InformixDialect',
'jdbc.driver': 'com.informix.jdbc.IfxDriver',
@ -157,6 +179,13 @@ ext {
'jdbc.pass' : 'orm_test',
'jdbc.url' : 'jdbc:db2://' + dbHost + ':50000/orm_test'
],
db2_spatial_ci : [
'db.dialect' : 'org.hibernate.spatial.dialect.db2.DB2SpatialDialect',
'jdbc.driver': 'com.ibm.db2.jcc.DB2Driver',
'jdbc.user' : 'orm_test',
'jdbc.pass' : 'orm_test',
'jdbc.url' : 'jdbc:db2://' + dbHost + ':50000/orm_test'
],
hana : [
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
'jdbc.driver': 'com.sap.db.jdbc.Driver',
@ -189,6 +218,14 @@ ext {
// Disable prepared statement caching due to https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.04/en-US/78f2163887814223858e4369d18e2847.html
'jdbc.url' : 'jdbc:sap://' + dbHost + ':39017/?statementCacheSize=0'
],
hana_spatial_ci : [
'db.dialect' : 'org.hibernate.spatial.dialect.hana.HANASpatialDialect',
'jdbc.driver': 'com.sap.db.jdbc.Driver',
'jdbc.user' : 'SYSTEM',
'jdbc.pass' : 'H1bernate_test',
// Disable prepared statement caching due to https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.04/en-US/78f2163887814223858e4369d18e2847.html
'jdbc.url' : 'jdbc:sap://' + dbHost + ':39017/?statementCacheSize=0'
],
cockroachdb : [
'db.dialect' : 'org.hibernate.dialect.CockroachDialect',
// CockroachDB uses the same pgwire protocol as PostgreSQL, so the driver is the same.

View File

@ -72,7 +72,6 @@ import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.tuple.entity.EntityTuplizerFactory;
import static org.hibernate.cfg.AvailableSettings.ACQUIRE_CONNECTIONS;
import static org.hibernate.cfg.AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY;
import static org.hibernate.cfg.AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS;
import static org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY;
import static org.hibernate.cfg.AvailableSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTION;
@ -203,7 +202,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
private boolean orderUpdatesEnabled;
private boolean orderInsertsEnabled;
private boolean postInsertIdentifierDelayed;
private boolean enhancementAsProxyEnabled;
private boolean collectionsInDefaultFetchGroupEnabled;
// JPA callbacks
@ -357,7 +355,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
this.defaultNullPrecedence = NullPrecedence.parse( defaultNullPrecedence );
this.orderUpdatesEnabled = ConfigurationHelper.getBoolean( ORDER_UPDATES, configurationSettings );
this.orderInsertsEnabled = ConfigurationHelper.getBoolean( ORDER_INSERTS, configurationSettings );
this.enhancementAsProxyEnabled = ConfigurationHelper.getBoolean( ALLOW_ENHANCEMENT_AS_PROXY, configurationSettings );
this.callbacksEnabled = ConfigurationHelper.getBoolean( JPA_CALLBACKS_ENABLED, configurationSettings, true );
@ -1191,11 +1188,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
return callbacksEnabled;
}
@Override
public boolean isEnhancementAsProxyEnabled() {
return enhancementAsProxyEnabled;
}
@Override
public boolean isCollectionsInDefaultFetchGroupEnabled() {
return collectionsInDefaultFetchGroupEnabled;

View File

@ -460,11 +460,6 @@ public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOp
return delegate.areJPACallbacksEnabled();
}
@Override
public boolean isEnhancementAsProxyEnabled() {
return delegate.isEnhancementAsProxyEnabled();
}
@Override
public boolean isCollectionsInDefaultFetchGroupEnabled() {
return delegate.isCollectionsInDefaultFetchGroupEnabled();

View File

@ -322,9 +322,12 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
/**
* Can bytecode-enhanced entity classes be used as a "proxy"?
*
* @deprecated (since 5.5) use of enhanced proxies is always enabled
*/
@Deprecated
default boolean isEnhancementAsProxyEnabled() {
return false;
return true;
}
/**

View File

@ -31,7 +31,6 @@ public class EnhancementHelper {
public static boolean includeInBaseFetchGroup(
Property bootMapping,
boolean isEnhanced,
boolean allowEnhancementAsProxy,
boolean collectionsInDefaultFetchGroupEnabled) {
final Value value = bootMapping.getValue();
@ -57,7 +56,16 @@ public class EnhancementHelper {
}
// include it in the base fetch group so long as the config allows
// using the FK to create an "enhancement proxy"
return allowEnhancementAsProxy;
//return allowEnhancementAsProxy;
// ^^ previously we had to explicitly enable use of enhanced proxies.
// for the moment just return `true` assuming we can.
//
// there are cases where this block overall misses quite a few cases
// where it returns the least optimal value. This is true even outside
// this enhanced-proxy point
//
// those will all be addressed in the commits for HHH-13658
return true;
}
}

View File

@ -34,7 +34,6 @@ public class LazyAttributesMetadata implements Serializable {
public static LazyAttributesMetadata from(
PersistentClass mappedEntity,
boolean isEnhanced,
boolean allowEnhancementAsProxy,
boolean collectionsInDefaultFetchGroupEnabled) {
final Map<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap = new LinkedHashMap<>();
final Map<String, Set<String>> fetchGroupToAttributesMap = new HashMap<>();
@ -48,7 +47,6 @@ public class LazyAttributesMetadata implements Serializable {
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
property,
isEnhanced,
allowEnhancementAsProxy,
collectionsInDefaultFetchGroupEnabled
);
if ( lazy ) {

View File

@ -926,7 +926,11 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
* the results of those methods
*
* @implSpec See {@link org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor}
*
* @deprecated (as of 5.5) with no replacement. When using enhancement based lazy loading
* using the enhanced class as proxy is always used when appropriate.
*/
@Deprecated
String ALLOW_ENHANCEMENT_AS_PROXY = "hibernate.bytecode.allow_enhancement_as_proxy";
/**

View File

@ -238,14 +238,15 @@ public class OneToOneSecondPass implements SecondPass {
boolean referenceToPrimaryKey = referencesDerivedId || mappedBy == null;
value.setReferenceToPrimaryKey( referenceToPrimaryKey );
// If the other side is a derived ID, and both sides are eager using FetchMode.JOIN,
// prevent an infinite loop of attempts to resolve identifiers by making
// this side use FetchMode.SELECT.
// If the other side is an entity with an ID that is derived from
// this side's owner entity, and both sides of the association are eager,
// then this side must be set to FetchMode.SELECT; otherwise,
// there will be an infinite loop attempting to load the derived ID on
// the opposite side.
if ( referencesDerivedId &&
!value.isLazy() &&
value.getFetchMode() == FetchMode.JOIN &&
!otherSideProperty.isLazy() &&
otherSideProperty.getValue().getFetchMode() == FetchMode.JOIN ) {
!otherSideProperty.isLazy() ) {
value.setFetchMode( FetchMode.SELECT );
}

View File

@ -252,16 +252,11 @@ public class DefaultLoadEventListener implements LoadEventListener {
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
final boolean allowBytecodeProxy = factory
.getSessionFactoryOptions()
.isEnhancementAsProxyEnabled();
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
final boolean entityHasHibernateProxyFactory = persister.getRepresentationStrategy().getProxyFactory() != null;
// Check for the case where we can use the entity itself as a proxy
if ( options.isAllowProxyCreation()
&& allowBytecodeProxy
&& entityMetamodel.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() ) {
// if there is already a managed entity instance associated with the PC, return it
final Object managed = persistenceContext.getEntity( keyToLoad );

View File

@ -365,8 +365,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
}
if ( incoming instanceof PersistentAttributeInterceptable
&& persister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
&& source.getSessionFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled() ) {
&& persister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() ) {
final PersistentAttributeInterceptor incomingInterceptor = ( (PersistentAttributeInterceptable) incoming ).$$_hibernate_getInterceptor();
final PersistentAttributeInterceptor managedInterceptor = ( (PersistentAttributeInterceptable) managed ).$$_hibernate_getInterceptor();

View File

@ -56,12 +56,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
private final PersistenceContext temporaryPersistenceContext = new StatefulPersistenceContext( this );
private final boolean connectionProvided;
private final boolean allowBytecodeProxy;
public StatelessSessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
super( factory, options );
connectionProvided = options.getConnection() != null;
allowBytecodeProxy = getFactory().getSessionFactoryOptions().isEnhancementAsProxyEnabled();
}
@Override
@ -290,7 +288,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
final BytecodeEnhancementMetadata bytecodeEnhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
if ( allowBytecodeProxy && bytecodeEnhancementMetadata.isEnhancedForLazyLoading() ) {
if ( bytecodeEnhancementMetadata.isEnhancedForLazyLoading() ) {
// if the entity defines a HibernateProxy factory, see if there is an
// existing proxy associated with the PC - and if so, use it

View File

@ -244,7 +244,7 @@ public class Property implements Serializable, MetaAttributable {
* @apiNote This form reports whether the property is considered part of the
* base fetch group based solely on the mapping information. However,
* {@link EnhancementHelper#includeInBaseFetchGroup} is used internally to make that
* decision to account for {@link org.hibernate.cfg.AvailableSettings#ALLOW_ENHANCEMENT_AS_PROXY}
* decision to account for other details
*/
public boolean isLazy() {
if ( value instanceof ToOne ) {

View File

@ -866,7 +866,6 @@ public abstract class AbstractEntityPersister
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
entityMetamodel.isInstrumented(),
sessionFactoryOptions.isEnhancementAsProxyEnabled(),
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
);
@ -946,7 +945,6 @@ public abstract class AbstractEntityPersister
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
entityMetamodel.isInstrumented(),
sessionFactoryOptions.isEnhancementAsProxyEnabled(),
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
);
while ( colIter.hasNext() ) {

View File

@ -174,7 +174,6 @@ public final class PropertyFactory {
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
property,
lazyAvailable,
sessionFactoryOptions.isEnhancementAsProxyEnabled(),
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
);

View File

@ -38,12 +38,11 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
PersistentClass persistentClass,
Set<String> identifierAttributeNames,
CompositeType nonAggregatedCidMapper,
boolean allowEnhancementAsProxy,
boolean collectionsInDefaultFetchGroupEnabled) {
final Class mappedClass = persistentClass.getMappedClass();
final boolean enhancedForLazyLoading = PersistentAttributeInterceptable.class.isAssignableFrom( mappedClass );
final LazyAttributesMetadata lazyAttributesMetadata = enhancedForLazyLoading
? LazyAttributesMetadata.from( persistentClass, true, allowEnhancementAsProxy, collectionsInDefaultFetchGroupEnabled )
? LazyAttributesMetadata.from( persistentClass, true, collectionsInDefaultFetchGroupEnabled )
: LazyAttributesMetadata.nonEnhanced( persistentClass.getEntityName() );
return new BytecodeEnhancementMetadataPojoImpl(

View File

@ -167,7 +167,6 @@ public class EntityMetamodel implements Serializable {
persistentClass,
idAttributeNames,
nonAggregatedCidMapper,
sessionFactoryOptions.isEnhancementAsProxyEnabled(),
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
);
}
@ -250,7 +249,6 @@ public class EntityMetamodel implements Serializable {
boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
prop,
bytecodeEnhancementMetadata.isEnhancedForLazyLoading(),
sessionFactoryOptions.isEnhancementAsProxyEnabled(),
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled()
);

View File

@ -19,7 +19,6 @@ import javax.persistence.OneToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
@ -29,14 +28,12 @@ import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctionalTestCase {
private Foo foo;
@Test
@TestForIssue(jiraKey = "HHH-14390")
@FailureExpected(jiraKey = "HHH-14390")
public void testQuery() {
doInHibernate( this::sessionFactory, session -> {
@ -52,7 +49,6 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
@Test
@TestForIssue(jiraKey = "HHH-14390")
@FailureExpected(jiraKey = "HHH-14390")
public void testQueryById() {
doInHibernate( this::sessionFactory, session -> {
@ -66,23 +62,8 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
});
}
@Test
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
doInHibernate( this::sessionFactory, session -> {
Bar newBar = session.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
});
}
@Test
@TestForIssue(jiraKey = "HHH-14390")
@FailureExpected(jiraKey = "HHH-14390")
public void testFindByPrimaryKey() {
doInHibernate( this::sessionFactory, session -> {

View File

@ -18,7 +18,6 @@ import javax.persistence.OneToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
@ -28,7 +27,6 @@ import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
public class OneToOneLazyDerivedIdFetchModeSelectTest extends BaseCoreFunctionalTestCase {
private Foo foo;
@ -63,20 +61,6 @@ public class OneToOneLazyDerivedIdFetchModeSelectTest extends BaseCoreFunctional
});
}
@Test
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
doInHibernate( this::sessionFactory, session -> {
Bar newBar = session.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
});
}
@Test
@TestForIssue(jiraKey = "HHH-14390")
public void testFindByPrimaryKey() {

View File

@ -11,6 +11,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
@ -18,7 +19,6 @@ import org.hibernate.query.Query;
import org.hibernate.Session;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
@ -80,7 +80,6 @@ public class OneToOneWithDerivedIdentityTest extends BaseCoreFunctionalTestCase
@Test
@TestForIssue(jiraKey = "HHH-14389")
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
Session s = openSession();
s.beginTransaction();
@ -95,13 +94,15 @@ public class OneToOneWithDerivedIdentityTest extends BaseCoreFunctionalTestCase
assertEquals( foo.getId(), bar.getFoo().getId() );
s.clear();
Bar newBar = s.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
try {
s.find( Bar.class, foo );
fail( "Should have thrown IllegalArgumentException" );
}
catch(IllegalArgumentException expected) {
}
finally {
s.getTransaction().rollback();
}
s.close();
}

View File

@ -17,7 +17,6 @@ import javax.persistence.OneToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
@ -27,7 +26,6 @@ import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctionalTestCase {
private Foo foo;
@ -61,20 +59,6 @@ public class OneToOneEagerDerivedIdFetchModeSelectTest extends BaseCoreFunctiona
});
}
@Test
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
doInHibernate( this::sessionFactory, session -> {
Bar newBar = session.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
});
}
@Test
@TestForIssue(jiraKey = "HHH-14390")
public void testFindByPrimaryKey() {

View File

@ -17,7 +17,6 @@ import javax.persistence.OneToOne;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.After;
@ -27,7 +26,6 @@ import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
public class OneToOneLazyDerivedIdFetchModeSelectTest extends BaseCoreFunctionalTestCase {
private Foo foo;
@ -62,20 +60,6 @@ public class OneToOneLazyDerivedIdFetchModeSelectTest extends BaseCoreFunctional
});
}
@Test
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
doInHibernate( this::sessionFactory, session -> {
Bar newBar = session.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
});
}
@Test
@TestForIssue(jiraKey = "HHH-14390")
public void testFindByPrimaryKey() {

View File

@ -22,6 +22,7 @@ import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -64,6 +65,10 @@ public class CascadeDeleteManyToOneTest extends BaseCoreFunctionalTestCase {
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testManagedWithUninitializedAssociation() {
// Delete the Child
doInHibernate(
@ -109,6 +114,10 @@ public class CascadeDeleteManyToOneTest extends BaseCoreFunctionalTestCase {
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testDetachedWithUninitializedAssociation() {
final Child detachedChild = doInHibernate(
this::sessionFactory, s -> {
@ -136,6 +145,10 @@ public class CascadeDeleteManyToOneTest extends BaseCoreFunctionalTestCase {
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testDetachedWithInitializedAssociation() {
final Child detachedChild = doInHibernate(
this::sessionFactory, s -> {

View File

@ -19,6 +19,7 @@ import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
@ -54,6 +55,10 @@ public class CascadeOnUninitializedTest extends BaseNonConfigCoreFunctionalTestC
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testMergeDetachedEnhancedEntityWithUninitializedManyToOne() {
Person person = persistPersonWithManyToOne();
@ -81,6 +86,10 @@ public class CascadeOnUninitializedTest extends BaseNonConfigCoreFunctionalTestC
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testDeleteEnhancedEntityWithUninitializedManyToOne() {
Person person = persistPersonWithManyToOne();

View File

@ -26,6 +26,7 @@ import org.hibernate.bytecode.enhance.spi.UnloadedField;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
@ -53,6 +54,10 @@ import static org.junit.Assert.assertTrue;
EnhancerTestContext.class, // supports laziness and dirty-checking
BidirectionalLazyTest.NoDirtyCheckEnhancementContext.class // supports laziness; does not support dirty-checking
})
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public class BidirectionalLazyTest extends BaseCoreFunctionalTestCase {
public Class<?>[] getAnnotatedClasses() {

View File

@ -6,17 +6,9 @@
*/
package org.hibernate.test.bytecode.enhancement.lazy;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@ -26,20 +18,30 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.checkDirtyTracking;
import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.getFieldByReflection;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* @author Luis Barreiro
@ -82,13 +84,15 @@ public class LazyLoadingTest extends BaseCoreFunctionalTestCase {
public void test() {
doInHibernate( this::sessionFactory, s -> {
Child loadedChild = s.load( Child.class, lastChildID );
assertThat( loadedChild, not( instanceOf( HibernateProxy.class ) ) );
assertThat( loadedChild, instanceOf( PersistentAttributeInterceptable.class ) );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
assertThat( interceptor, instanceOf( EnhancementAsProxyLazinessInterceptor.class ) );
Object nameByReflection = getFieldByReflection( loadedChild, "name" );
assertNotNull( "Non-lazy field 'name' was not loaded", nameByReflection );
Object parentByReflection = getFieldByReflection( loadedChild, "parent" );
assertNull( "Lazy field 'parent' is initialized", parentByReflection );
assertFalse( loadedChild instanceof HibernateProxy );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "name" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "parent" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "children" ), is( false ) );
Parent loadedParent = loadedChild.parent;
assertThat( loadedChild.name, notNullValue() );
@ -97,23 +101,18 @@ public class LazyLoadingTest extends BaseCoreFunctionalTestCase {
checkDirtyTracking( loadedChild );
parentByReflection = getFieldByReflection( loadedChild, "parent" );
Object childrenByReflection = getFieldByReflection( loadedParent, "children" );
assertNotNull( "Lazy field 'parent' is not loaded", parentByReflection );
assertNull( "Lazy field 'children' is initialized", childrenByReflection );
assertFalse( loadedParent instanceof HibernateProxy );
assertEquals( parentID, loadedParent.id );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "name" ), is( true ) );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "parent" ), is( true ) );
assertThat( Hibernate.isPropertyInitialized( loadedChild, "children" ), is( true ) );
Collection<Child> loadedChildren = loadedParent.children;
assertThat( Hibernate.isInitialized( loadedChildren ), is( false ) );
checkDirtyTracking( loadedChild );
checkDirtyTracking( loadedParent );
childrenByReflection = getFieldByReflection( loadedParent, "children" );
assertNotNull( "Lazy field 'children' is not loaded", childrenByReflection );
assertFalse( loadedChildren instanceof HibernateProxy );
assertEquals( CHILDREN_SIZE, loadedChildren.size() );
assertTrue( loadedChildren.contains( loadedChild ) );
loadedChildren.size();
assertThat( Hibernate.isInitialized( loadedChildren ), is( true ) );
} );
}

View File

@ -21,6 +21,7 @@ import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
@ -43,6 +44,10 @@ import static org.junit.Assert.assertFalse;
public class NaturalIdInUninitializedAssociationTest extends BaseNonConfigCoreFunctionalTestCase {
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testImmutableNaturalId() {
inTransaction(
session -> {
@ -60,6 +65,10 @@ public class NaturalIdInUninitializedAssociationTest extends BaseNonConfigCoreFu
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void testMutableNaturalId() {
inTransaction(
session -> {

View File

@ -1,323 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.test.bytecode.enhancement.lazy;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.StatelessSession;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.query.Query;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Andrea Boriero
*/
@RunWith(BytecodeEnhancerRunner.class)
public class QueryScrollingWithInheritanceEagerManyToOneTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "false" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {
super.configureSessionFactoryBuilder( sfb );
sfb.applyStatisticsSupport( true );
sfb.applySecondLevelCacheSupport( false );
sfb.applyQueryCacheSupport( false );
}
@Override
protected void applyMetadataSources(MetadataSources sources) {
super.applyMetadataSources( sources );
sources.addAnnotatedClass( EmployeeParent.class );
sources.addAnnotatedClass( Employee.class );
sources.addAnnotatedClass( OtherEntity.class );
}
@Test
public void testScrollableWithStatelessSession() {
final StatisticsImplementor stats = sessionFactory().getStatistics();
stats.clear();
ScrollableResults scrollableResults = null;
final StatelessSession statelessSession = sessionFactory().openStatelessSession();
try {
statelessSession.beginTransaction();
Query<Employee> query = statelessSession.createQuery(
"select distinct e from Employee e left join fetch e.otherEntities order by e.dept",
Employee.class
);
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
final Employee employee = (Employee) scrollableResults.get();
assertThat( Hibernate.isPropertyInitialized( employee, "otherEntities" ), is( true ) );
assertThat( Hibernate.isInitialized( employee.getOtherEntities() ), is( true ) );
if ( "ENG1".equals( employee.getDept() ) ) {
assertThat( employee.getOtherEntities().size(), is( 2 ) );
for ( OtherEntity otherEntity : employee.getOtherEntities() ) {
if ( "test1".equals( otherEntity.id ) ) {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( true ) );
assertThat( otherEntity.employeeParent, is( employee ) );
}
else {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( true ) );
assertThat( Hibernate.isInitialized( otherEntity.employeeParent ), is( true ) );
}
}
}
else {
assertThat( employee.getOtherEntities().size(), is( 0 ) );
}
}
statelessSession.getTransaction().commit();
assertThat( stats.getPrepareStatementCount(), is( 2L ) );
}
finally {
if ( scrollableResults != null ) {
scrollableResults.close();
}
if ( statelessSession.getTransaction().isActive() ) {
statelessSession.getTransaction().rollback();
}
statelessSession.close();
}
}
@Test
public void testScrollableWithSession() {
final StatisticsImplementor stats = sessionFactory().getStatistics();
stats.clear();
ScrollableResults scrollableResults = null;
final Session session = sessionFactory().openSession();
try {
session.beginTransaction();
Query<Employee> query = session.createQuery(
"select distinct e from Employee e left join fetch e.otherEntities order by e.dept",
Employee.class
);
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
final Employee employee = (Employee) scrollableResults.get();
assertThat( Hibernate.isPropertyInitialized( employee, "otherEntities" ), is( true ) );
assertThat( Hibernate.isInitialized( employee.getOtherEntities() ), is( true ) );
if ( "ENG1".equals( employee.getDept() ) ) {
assertThat( employee.getOtherEntities().size(), is( 2 ) );
for ( OtherEntity otherEntity : employee.getOtherEntities() ) {
if ( "test1".equals( otherEntity.id ) ) {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( true ) );
assertThat( otherEntity.employeeParent, is( employee ) );
}
else {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( true ) );
assertThat( Hibernate.isInitialized( otherEntity.employeeParent ), is( true ) );
}
}
}
else {
assertThat( employee.getOtherEntities().size(), is( 0 ) );
}
}
session.getTransaction().commit();
assertThat( stats.getPrepareStatementCount(), is( 2L ) );
}
finally {
if ( scrollableResults != null ) {
scrollableResults.close();
}
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
session.close();
}
}
@Before
public void prepareTestData() {
inTransaction(
session -> {
Employee e1 = new Employee( "ENG1" );
Employee e2 = new Employee( "ENG2" );
OtherEntity other1 = new OtherEntity( "test1" );
OtherEntity other2 = new OtherEntity( "test2" );
e1.getOtherEntities().add( other1 );
e1.getOtherEntities().add( other2 );
e1.getParentOtherEntities().add( other1 );
e1.getParentOtherEntities().add( other2 );
other1.employee = e1;
other2.employee = e1;
other1.employeeParent = e1;
other2.employeeParent = e2;
session.persist( other1 );
session.persist( other2 );
session.persist( e1 );
session.persist( e2 );
}
);
}
@After
public void cleanUpTestData() {
inTransaction(
session -> {
session.createQuery( "delete from OtherEntity" ).executeUpdate();
session.createQuery( "delete from Employee" ).executeUpdate();
session.createQuery( "delete from EmployeeParent" ).executeUpdate();
}
);
}
@Entity(name = "EmployeeParent")
@Table(name = "EmployeeParent")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public static abstract class EmployeeParent {
@Id
private String dept;
@OneToMany(targetEntity = OtherEntity.class, mappedBy = "employeeParent", fetch = FetchType.LAZY)
protected Set<OtherEntity> parentOtherEntities = new HashSet<>();
public Set<OtherEntity> getParentOtherEntities() {
if ( parentOtherEntities == null ) {
parentOtherEntities = new LinkedHashSet();
}
return parentOtherEntities;
}
public void setOtherEntities(Set<OtherEntity> pParentOtherEntites) {
parentOtherEntities = pParentOtherEntites;
}
public String getDept() {
return dept;
}
protected void setDept(String dept) {
this.dept = dept;
}
}
@Entity(name = "Employee")
@Table(name = "Employee")
public static class Employee extends EmployeeParent {
@OneToMany(targetEntity = OtherEntity.class, mappedBy = "employee", fetch = FetchType.LAZY)
protected Set<OtherEntity> otherEntities = new HashSet<>();
public Employee(String dept) {
this();
setDept( dept );
}
protected Employee() {
// this form used by Hibernate
}
public Set<OtherEntity> getOtherEntities() {
if ( otherEntities == null ) {
otherEntities = new LinkedHashSet();
}
return otherEntities;
}
public void setOtherEntities(Set<OtherEntity> pOtherEntites) {
otherEntities = pOtherEntites;
}
}
@Entity(name = "OtherEntity")
@Table(name = "OtherEntity")
public static class OtherEntity {
@Id
private String id;
@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "Employee_Id")
protected Employee employee = null;
@ManyToOne(fetch = FetchType.EAGER)
//@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "EmployeeParent_Id")
protected EmployeeParent employeeParent = null;
protected OtherEntity() {
// this form used by Hibernate
}
public OtherEntity(String id) {
this.id = id;
}
public String getId() {
return id;
}
}
}

View File

@ -1,306 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.test.bytecode.enhancement.lazy;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.StatelessSession;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.query.Query;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Andrea Boriero
*/
@RunWith(BytecodeEnhancerRunner.class)
public class QueryScrollingWithInheritanceTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {
super.configureSessionFactoryBuilder( sfb );
sfb.applyStatisticsSupport( true );
sfb.applySecondLevelCacheSupport( false );
sfb.applyQueryCacheSupport( false );
}
@Override
protected void applyMetadataSources(MetadataSources sources) {
super.applyMetadataSources( sources );
sources.addAnnotatedClass( EmployeeParent.class );
sources.addAnnotatedClass( Employee.class );
sources.addAnnotatedClass( OtherEntity.class );
}
@Test
public void testScrollableWithStatelessSession() {
final StatisticsImplementor stats = sessionFactory().getStatistics();
stats.clear();
ScrollableResults scrollableResults = null;
final StatelessSession statelessSession = sessionFactory().openStatelessSession();
try {
statelessSession.beginTransaction();
Query<Employee> query = statelessSession.createQuery(
"select distinct e from Employee e left join fetch e.otherEntities order by e.dept",
Employee.class
);
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
final Employee employee = (Employee) scrollableResults.get();
assertThat( Hibernate.isPropertyInitialized( employee, "otherEntities" ), is( true ) );
assertThat( Hibernate.isInitialized( employee.getOtherEntities() ), is( true ) );
if ( "ENG1".equals( employee.getDept() ) ) {
assertThat( employee.getOtherEntities().size(), is( 2 ) );
for ( OtherEntity otherEntity : employee.getOtherEntities() ) {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( false ) );
}
}
else {
assertThat( employee.getOtherEntities().size(), is( 0 ) );
}
}
statelessSession.getTransaction().commit();
assertThat( stats.getPrepareStatementCount(), is( 1L ) );
}
finally {
if ( scrollableResults != null ) {
scrollableResults.close();
}
if ( statelessSession.getTransaction().isActive() ) {
statelessSession.getTransaction().rollback();
}
statelessSession.close();
}
}
@Test
public void testScrollableWithSession() {
final StatisticsImplementor stats = sessionFactory().getStatistics();
stats.clear();
ScrollableResults scrollableResults = null;
final Session session = sessionFactory().openSession();
try {
session.beginTransaction();
Query<Employee> query = session.createQuery(
"select distinct e from Employee e left join fetch e.otherEntities order by e.dept",
Employee.class
);
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
final Employee employee = (Employee) scrollableResults.get();
assertThat( Hibernate.isPropertyInitialized( employee, "otherEntities" ), is( true ) );
assertThat( Hibernate.isInitialized( employee.getOtherEntities() ), is( true ) );
if ( "ENG1".equals( employee.getDept() ) ) {
assertThat( employee.getOtherEntities().size(), is( 2 ) );
for ( OtherEntity otherEntity : employee.getOtherEntities() ) {
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employee" ), is( false ) );
assertThat( Hibernate.isPropertyInitialized( otherEntity, "employeeParent" ), is( false ) );
}
}
else {
assertThat( employee.getOtherEntities().size(), is( 0 ) );
}
}
session.getTransaction().commit();
assertThat( stats.getPrepareStatementCount(), is( 1L ) );
}
finally {
if ( scrollableResults != null ) {
scrollableResults.close();
}
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
session.close();
}
}
@Before
public void prepareTestData() {
inTransaction(
session -> {
Employee e1 = new Employee( "ENG1" );
Employee e2 = new Employee( "ENG2" );
OtherEntity other1 = new OtherEntity( "test1" );
OtherEntity other2 = new OtherEntity( "test2" );
e1.getOtherEntities().add( other1 );
e1.getOtherEntities().add( other2 );
e1.getParentOtherEntities().add( other1 );
e1.getParentOtherEntities().add( other2 );
other1.employee = e1;
other2.employee = e1;
other1.employeeParent = e1;
other2.employeeParent = e2;
session.persist( other1 );
session.persist( other2 );
session.persist( e1 );
session.persist( e2 );
}
);
}
@After
public void cleanUpTestData() {
inTransaction(
session -> {
session.createQuery( "delete from OtherEntity" ).executeUpdate();
session.createQuery( "delete from Employee" ).executeUpdate();
session.createQuery( "delete from EmployeeParent" ).executeUpdate();
}
);
}
@Entity(name = "EmployeeParent")
@Table(name = "EmployeeParent")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public static abstract class EmployeeParent {
@Id
private String dept;
@OneToMany(targetEntity = OtherEntity.class, mappedBy = "employeeParent", fetch = FetchType.LAZY)
protected Set<OtherEntity> parentOtherEntities = new HashSet<>();
public Set<OtherEntity> getParentOtherEntities() {
if ( parentOtherEntities == null ) {
parentOtherEntities = new LinkedHashSet();
}
return parentOtherEntities;
}
public void setOtherEntities(Set<OtherEntity> pParentOtherEntites) {
parentOtherEntities = pParentOtherEntites;
}
public String getDept() {
return dept;
}
protected void setDept(String dept) {
this.dept = dept;
}
}
@Entity(name = "Employee")
@Table(name = "Employee")
public static class Employee extends EmployeeParent {
@OneToMany(targetEntity = OtherEntity.class, mappedBy = "employee", fetch = FetchType.LAZY)
protected Set<OtherEntity> otherEntities = new HashSet<>();
public Employee(String dept) {
this();
setDept( dept );
}
protected Employee() {
// this form used by Hibernate
}
public Set<OtherEntity> getOtherEntities() {
if ( otherEntities == null ) {
otherEntities = new LinkedHashSet();
}
return otherEntities;
}
public void setOtherEntities(Set<OtherEntity> pOtherEntites) {
otherEntities = pOtherEntites;
}
}
@Entity(name = "OtherEntity")
@Table(name = "OtherEntity")
public static class OtherEntity {
@Id
private String id;
@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "Employee_Id")
protected Employee employee = null;
@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "EmployeeParent_Id")
protected EmployeeParent employeeParent = null;
protected OtherEntity() {
// this form used by Hibernate
}
public OtherEntity(String id) {
this.id = id;
}
public String getId() {
return id;
}
}
}

View File

@ -174,12 +174,6 @@ public class StatelessQueryScrollingTest extends BaseNonConfigCoreFunctionalTest
);
}
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void applyMetadataSources(MetadataSources sources) {
super.applyMetadataSources( sources );

View File

@ -25,6 +25,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.stat.CacheRegionStatistics;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -52,6 +53,10 @@ public class UninitializedAssociationsInCacheTest extends BaseCoreFunctionalTest
@Test
@TestForIssue( jiraKey = "HHH-11766")
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void attributeLoadingFromCache() {
final AtomicLong bossId = new AtomicLong();
final AtomicLong teamleaderId = new AtomicLong();

View File

@ -23,6 +23,7 @@ import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
@ -48,6 +49,10 @@ import static org.junit.Assert.assertTrue;
EnhancerTestContext.class,
BidirectionalLazyGroupsTest.NoDirtyCheckEnhancementContext.class
})
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public class BidirectionalLazyGroupsTest extends BaseCoreFunctionalTestCase {
public Class<?>[] getAnnotatedClasses() {

View File

@ -12,6 +12,8 @@ import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -45,6 +47,10 @@ import static org.junit.Assert.assertNull;
*/
@TestForIssue( jiraKey = "HHH-11155" )
@RunWith( BytecodeEnhancerRunner.class )
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public class LazyGroupTest extends BaseCoreFunctionalTestCase {
@Override

View File

@ -26,6 +26,7 @@ import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -50,6 +51,10 @@ public class LazyNotFoundManyToOneNonUpdatableNonInsertableTest extends BaseCore
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void test() {
doInHibernate(
this::sessionFactory, session -> {

View File

@ -15,8 +15,6 @@ import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
@ -27,7 +25,10 @@ import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -37,6 +38,7 @@ import org.junit.runner.RunWith;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@TestForIssue( jiraKey = "HHH-12226")
@RunWith( BytecodeEnhancerRunner.class )
@ -51,7 +53,17 @@ public class LazyNotFoundOneToOneTest extends BaseCoreFunctionalTestCase {
};
}
@Override
protected void configure(Configuration configuration) {
super.configure(configuration);
configuration.setProperty( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void test() {
doInHibernate(
this::sessionFactory, session -> {

View File

@ -224,7 +224,6 @@ public class BatchFetchProxyTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
ssrb.applySetting( AvailableSettings.SHOW_SQL, true );

View File

@ -126,7 +126,6 @@ public class BidirectionalProxyTest extends BaseNonConfigCoreFunctionalTestCase
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -484,7 +484,6 @@ public class DeepInheritanceProxyTest extends BaseNonConfigCoreFunctionalTestCas
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -1288,7 +1288,6 @@ public class DeepInheritanceWithNonEntitiesProxyTest extends BaseNonConfigCoreFu
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -116,7 +116,6 @@ public class EntitySharedInCollectionAndToOneTest extends BaseNonConfigCoreFunct
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -509,7 +509,6 @@ public class FetchGraphTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -58,7 +58,6 @@ public class LazyCollectionDeletedAllowProxyTest extends BaseNonConfigCoreFuncti
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );
}

View File

@ -191,9 +191,6 @@ public class LazyGroupWithInheritanceAllowProxyTest extends BaseNonConfigCoreFun
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
// todo : this is the only difference between this test and LazyGroupWithInheritanceTest
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.USE_QUERY_CACHE, "false" );

View File

@ -15,6 +15,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.stat.Statistics;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
@ -38,6 +39,10 @@ import static org.junit.Assert.assertEquals;
@EnhancementOptions( lazyLoading = true )
public class LazyGroupWithInheritanceTest extends BaseNonConfigCoreFunctionalTestCase {
@Test
@FailureExpected(
jiraKey = "HHH-13658",
message = "Assertions specific to enhanced lazy loading but disallowing enhanced proxies, which is no longer valid"
)
public void queryEntityWithAssociationToAbstract() {
final Statistics stats = sessionFactory().getStatistics();
stats.clear();

View File

@ -57,12 +57,6 @@ import static org.junit.Assert.assertTrue;
@TestForIssue( jiraKey = "HHH-13640" )
@RunWith(BytecodeEnhancerRunner.class)
public class LazyToOnesNoProxyFactoryWithSubclassesStatefulTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {
super.configureSessionFactoryBuilder( sfb );

View File

@ -57,11 +57,6 @@ import static org.junit.Assert.assertTrue;
@TestForIssue( jiraKey = "HHH-13640" )
@RunWith(BytecodeEnhancerRunner.class)
public class LazyToOnesNoProxyFactoryWithSubclassesStatelessTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -47,12 +47,6 @@ import static org.junit.Assert.assertTrue;
@RunWith(BytecodeEnhancerRunner.class )
@EnhancementOptions(lazyLoading = true)
public class LazyToOnesProxyMergeWithSubclassesTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {
super.configureSessionFactoryBuilder( sfb );

View File

@ -43,11 +43,6 @@ import static org.junit.Assert.assertTrue;
@TestForIssue( jiraKey = "HHH-13640" )
@RunWith(BytecodeEnhancerRunner.class)
public class LazyToOnesProxyWithSubclassesStatelessTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -43,11 +43,6 @@ import static org.junit.Assert.assertTrue;
@TestForIssue( jiraKey = "HHH-13640" )
@RunWith(BytecodeEnhancerRunner.class)
public class LazyToOnesProxyWithSubclassesTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -159,7 +159,6 @@ public class LoadANonExistingEntityTest extends BaseNonConfigCoreFunctionalTestC
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -181,7 +181,6 @@ public class LoadANonExistingNotFoundBatchEntityTest extends BaseNonConfigCoreFu
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -161,7 +161,6 @@ public class LoadANonExistingNotFoundEntityTest extends BaseNonConfigCoreFunctio
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -41,7 +41,6 @@ public class MappedSuperclassWithEmbeddableTest extends BaseNonConfigCoreFunctio
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );

View File

@ -132,7 +132,6 @@ public class MapsIdProxyBidirectionalTest extends BaseNonConfigCoreFunctionalTes
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
ssrb.applySetting( AvailableSettings.SHOW_SQL, true );

View File

@ -101,7 +101,6 @@ public class MapsIdProxyUnidirectionalTest extends BaseNonConfigCoreFunctionalTe
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
ssrb.applySetting( AvailableSettings.SHOW_SQL, true );

View File

@ -118,7 +118,6 @@ public class MergeDetachedToProxyTest extends BaseNonConfigCoreFunctionalTestCas
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -170,7 +170,6 @@ public class MergeProxyTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -74,7 +74,6 @@ public class NaturalIdInUninitializedProxyTest extends BaseNonConfigCoreFunction
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -54,7 +54,6 @@ public class ProxyDeletionTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
}

View File

@ -46,7 +46,6 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest extend
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override

View File

@ -36,11 +36,6 @@ import static org.junit.Assert.assertTrue;
@RunWith(BytecodeEnhancerRunner.class)
@EnhancementOptions(lazyLoading = true,inlineDirtyChecking = true)
public class ProxyInitializeAndUpdateInlineDirtyTrackingTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -37,11 +37,6 @@ import static org.junit.Assert.assertTrue;
@RunWith(BytecodeEnhancerRunner.class)
@EnhancementOptions(lazyLoading = true)
public class ProxyInitializeAndUpdateTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -49,11 +49,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
*/
@RunWith(BytecodeEnhancerRunner.class)
public class QueryScrollingWithInheritanceProxyEagerManyToOneTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override
protected void configureSessionFactoryBuilder(SessionFactoryBuilder sfb) {

View File

@ -66,7 +66,6 @@ public class SetIdentifierOnAEnhancedProxyTest extends BaseNonConfigCoreFunction
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );

View File

@ -43,7 +43,6 @@ public class SharingReferenceTest extends BaseNonConfigCoreFunctionalTestCase {
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -61,7 +61,6 @@ public class SimpleUpdateTestWithLazyLoading extends BaseNonConfigCoreFunctional
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );

View File

@ -55,7 +55,6 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking extends BaseN
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
ssrb.applySetting( AvailableSettings.ENABLE_LAZY_LOAD_NO_TRANS, "true" );

View File

@ -46,7 +46,6 @@ public abstract class AbstractBatchingTest extends BaseNonConfigCoreFunctionalTe
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -41,7 +41,6 @@ public class DirtyCheckPrivateUnMappedCollectionTest extends BaseNonConfigCoreFu
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -44,7 +44,6 @@ public class EntityWithMutableAttributesTest extends BaseNonConfigCoreFunctional
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -41,7 +41,6 @@ public class LoadAndUpdateEntitiesWithCollectionsTest extends BaseNonConfigCoreF
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -63,7 +63,6 @@ public class ManyToOnePropertyAccessByFieldTest extends BaseNonConfigCoreFunctio
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -46,7 +46,6 @@ public class ManyToOneWithEmbeddedAndNotOptionalFieldTest extends BaseNonConfigC
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.FORMAT_SQL, "false" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -43,7 +43,6 @@ public class SimpleDynamicUpdateTest extends BaseNonConfigCoreFunctionalTestCase
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -44,7 +44,6 @@ public class DynamicUpdateAndCollectionsTest extends BaseNonConfigCoreFunctional
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
super.configureStandardServiceRegistryBuilder( ssrb );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
ssrb.applySetting( AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, "100" );
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
}

View File

@ -43,7 +43,6 @@ public class EnhancedProxyCacheTest extends BaseCoreFunctionalTestCase {
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
cfg.setProperty( Environment.USE_SECOND_LEVEL_CACHE, "true" );
}

View File

@ -37,7 +37,6 @@ public class InstrumentedProxyLazyToOneTest extends BaseNonConfigCoreFunctionalT
@Override
protected void configureStandardServiceRegistryBuilder(StandardServiceRegistryBuilder ssrb) {
ssrb.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" );
ssrb.applySetting( AvailableSettings.ALLOW_ENHANCEMENT_AS_PROXY, "true" );
}
@Override

View File

@ -4,4 +4,4 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'org.postgresql:postgresql:42.2.2'
jdbcDependency 'org.postgresql:postgresql:42.2.16'

View File

@ -8,10 +8,9 @@
hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql://localhost:9432/
hibernate.connection.username hibern8
hibernate.connection.password hibern8
hibernate.connection.url jdbc:postgresql://localhost/hibernate_orm_test
hibernate.connection.username hibernate_orm_test
hibernate.connection.password hibernate_orm_test
hibernate.show_sql true
hibernate.format_sql true

View File

@ -25,7 +25,7 @@ dependencies {
testCompile(libraries.junit)
testCompile(project(':hibernate-testing'))
testCompile([group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'])
testCompile([group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.8.0'])
testCompile(libraries.validation)
testCompile(libraries.jandex)
testCompile(libraries.classmate)

View File

@ -65,8 +65,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getAlphaShape( 1 );
String hql = format(
Locale.ENGLISH,
"SELECT id, alphashape(geom, 1) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Point', 'ST_MultiPoint')",
pckg
"SELECT id, alphashape(geom, 1) FROM %s where geometrytype(geom) in ('ST_Point', 'ST_MultiPoint')",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -84,8 +84,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void area(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getArea();
String hql = format(
"SELECT id, area(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon')",
pckg
"SELECT id, area(geom) FROM %s where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon')",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -102,7 +102,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void asewkb(String pckg) throws SQLException {
Map<Integer, byte[]> dbexpected = hanaExpectationsFactory.getAsEWKB();
String hql = format( "SELECT id, asewkb(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, asewkb(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -118,7 +118,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void asewkt(String pckg) throws SQLException {
Map<Integer, String> dbexpected = hanaExpectationsFactory.getAsEWKT();
String hql = format( "SELECT id, asewkt(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, asewkt(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -134,7 +134,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void asgeojson(String pckg) throws SQLException {
Map<Integer, String> dbexpected = hanaExpectationsFactory.getAsGeoJSON();
String hql = format( "SELECT id, asgeojson(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, asgeojson(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -150,7 +150,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void assvg(String pckg) throws SQLException {
Map<Integer, String> dbexpected = hanaExpectationsFactory.getAsSVG();
String hql = format( "SELECT id, assvg(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, assvg(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -167,8 +167,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void assvgaggr(String pckg) throws SQLException {
Map<Integer, String> dbexpected = hanaExpectationsFactory.getAsSVGAggr();
String hql = format(
"SELECT cast(count(g) as int), assvgaggr(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
pckg
"SELECT cast(count(g) as int), assvgaggr(geom) FROM %s g",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -185,7 +185,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void aswkb(String pckg) throws SQLException {
Map<Integer, byte[]> dbexpected = hanaExpectationsFactory.getAsWKB();
String hql = format( "SELECT id, aswkb(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, aswkb(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -201,7 +201,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void aswkt(String pckg) throws SQLException {
Map<Integer, String> dbexpected = hanaExpectationsFactory.getAsWKT();
String hql = format( "SELECT id, aswkt(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, aswkt(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -218,8 +218,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void convexhullaggr(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getConvexHullAggr();
String hql = format(
"SELECT cast(count(g) as int), convexhullaggr(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
pckg
"SELECT cast(count(g) as int), convexhullaggr(geom) FROM %s g",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -237,8 +237,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void centroid(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getCentroid();
String hql = format(
"SELECT id, centroid(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_Polygon'",
pckg
"SELECT id, centroid(geom) FROM %s g where geometrytype(geom) = 'ST_Polygon'",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -255,7 +255,7 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void coorddim(String pckg) throws SQLException {
Map<Integer, Integer> dbexpected = hanaExpectationsFactory.getCoordDim();
String hql = format( "SELECT id, coorddim(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
String hql = format( "SELECT id, coorddim(geom) FROM %s", entityName( pckg ) );
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -272,8 +272,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void coveredby(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getCoveredBy( expectationsFactory.getTestPolygon() );
String hql = format(
"SELECT id, coveredby(geom, :filter) FROM org.hibernate.spatial.integration.%s.GeomEntity where coveredby(geom, :filter) = true and srid(geom) = %d",
pckg,
"SELECT id, coveredby(geom, :filter) FROM %s where coveredby(geom, :filter) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@ -293,8 +293,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void covers(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getCovers( expectationsFactory.getTestPolygon() );
String hql = format(
"SELECT id, covers(geom, :filter) FROM org.hibernate.spatial.integration.%s.GeomEntity where covers(geom, :filter) = true and srid(geom) = %d",
pckg,
"SELECT id, covers(geom, :filter) FROM %s where covers(geom, :filter) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@ -314,8 +314,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void endpoint(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getEndPoint();
String hql = format(
"SELECT id, endpoint(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_LineString'",
pckg
"SELECT id, endpoint(geom) FROM %s g where geometrytype(geom) = 'ST_LineString'",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -333,8 +333,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void envelopeaggr(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getEnvelopeAggr();
String hql = format(
"SELECT cast(count(g) as int), envelopeaggr(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
pckg
"SELECT cast(count(g) as int), envelopeaggr(geom) FROM %s g",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -352,8 +352,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void exteriorring(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getExteriorRing();
String hql = format(
"SELECT id, exteriorring(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_Polygon'",
pckg
"SELECT id, exteriorring(geom) FROM %s g where geometrytype(geom) = 'ST_Polygon'",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -373,9 +373,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
byte[] ewkb = writer.write( expectationsFactory.getTestPolygon() );
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromEWKB( ewkb );
String hql = format(
"SELECT 1, cast(geomfromewkb(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
"SELECT 1, cast(geomfromewkb(:param) as %s) FROM %s g",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "param", ewkb );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -396,9 +396,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
String ewkt = "SRID=" + expectationsFactory.getTestSrid() + ";" + writer.write( expectationsFactory.getTestPolygon() );
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromEWKT( ewkt );
String hql = format(
"SELECT 1, cast(geomfromewkt(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
"SELECT 1, cast(geomfromewkt(:param) as %s) FROM %s g",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "param", ewkt );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -418,9 +418,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
String text = expectationsFactory.getTestPolygon().toText();
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromText( text );
String hql = format(
"SELECT 1, cast(geomfromtext(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
"SELECT 1, cast(geomfromtext(:param) as %s) FROM %s g",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "param", text );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -441,9 +441,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
byte[] wkb = writer.write( expectationsFactory.getTestPolygon() );
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromWKB( wkb );
String hql = format(
"SELECT 1, cast(geomfromwkb(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
"SELECT 1, cast(geomfromwkb(:param) as %s) FROM %s g",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "param", wkb );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -464,9 +464,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
String wkt = writer.write( expectationsFactory.getTestPolygon() );
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeomFromWKT( wkt );
String hql = format(
"SELECT 1, cast(geomfromwkt(:param) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
"SELECT 1, cast(geomfromwkt(:param) as %s) FROM %s g",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "param", wkt );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -485,9 +485,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void geometryn(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getGeometryN( 1 );
String hql = format(
"SELECT id, cast(geometryn(geom, :n) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_GeometryCollection'",
"SELECT id, cast(geometryn(geom, :n) as %s) FROM %s g where geometrytype(geom) = 'ST_GeometryCollection'",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "n", 1 );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -506,9 +506,9 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void interiorringn(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getInteriorRingN( 1 );
String hql = format(
"SELECT id, cast(interiorringn(geom, :n) as %s) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_Polygon'",
"SELECT id, cast(interiorringn(geom, :n) as %s) FROM %s g where geometrytype(geom) = 'ST_Polygon'",
getGeometryTypeFromPackage( pckg ),
pckg
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "n", 1 );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@ -527,8 +527,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void intersectionaggr(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getIntersectionAggr();
String hql = format(
"SELECT cast(count(g) as int), intersectionaggr(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
pckg
"SELECT cast(count(g) as int), intersectionaggr(geom) FROM %s g",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -549,8 +549,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
expectationsFactory.getTestPoint()
);
String hql = format(
"SELECT id, intersectsrect(geom, :pmin, :pmax) FROM org.hibernate.spatial.integration.%s.GeomEntity where intersectsrect(geom, :pmin, :pmax) = true and srid(geom) = %d",
pckg,
"SELECT id, intersectsrect(geom, :pmin, :pmax) FROM %s where intersectsrect(geom, :pmin, :pmax) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
Map<String, Object> params = createQueryParams( "pmin", expectationsFactory.getTestPoint().reverse() );
@ -571,8 +571,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void is3d(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getIs3D();
String hql = format(
"SELECT id, is3d(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where is3d(geom) = true and srid(geom) = %d",
pckg,
"SELECT id, is3d(geom) FROM %s where is3d(geom) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -591,8 +591,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void isclosed(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getIsClosed();
String hql = format(
"SELECT id, isclosed(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_LineString', 'ST_MultiLineString') and isclosed(geom) = true and srid(geom) = %d",
pckg,
"SELECT id, isclosed(geom) FROM %s where geometrytype(geom) in ('ST_LineString', 'ST_MultiLineString') and isclosed(geom) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -611,8 +611,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void ismeasured(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getIsMeasured();
String hql = format(
"SELECT id, ismeasured(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where ismeasured(geom) = true and srid(geom) = %d",
pckg,
"SELECT id, ismeasured(geom) FROM %s where ismeasured(geom) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -631,8 +631,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void isring(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getIsRing();
String hql = format(
"SELECT id, isring(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
pckg,
"SELECT id, isring(geom) FROM %s where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -651,8 +651,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void isvalid(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getIsValid();
String hql = format(
"SELECT id, isvalid(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where isvalid(geom) = true and srid(geom) = %d",
pckg,
"SELECT id, isvalid(geom) FROM %s where isvalid(geom) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -671,8 +671,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void length(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getLength();
String hql = format(
"SELECT id, length(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_LineString', 'ST_MultiLineString') and srid(geom) = %d",
pckg,
"SELECT id, length(geom) FROM %s where geometrytype(geom) in ('ST_LineString', 'ST_MultiLineString') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -691,8 +691,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void m(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getM();
String hql = format(
"SELECT id, m(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
pckg,
"SELECT id, m(geom) FROM %s where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -711,8 +711,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void mmax(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getMMax();
String hql = format(
"SELECT id, mmax(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, mmax(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -730,8 +730,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void mmin(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getMMin();
String hql = format(
"SELECT id, mmin(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, mmin(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -749,8 +749,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void numgeometries(String pckg) throws SQLException {
Map<Integer, Integer> dbexpected = hanaExpectationsFactory.getNumGeometries();
String hql = format(
"SELECT id, numgeometries(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_GeometryCollection') and srid(geom) = %d",
pckg,
"SELECT id, numgeometries(geom) FROM %s where geometrytype(geom) in ('ST_GeometryCollection') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -769,8 +769,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void numinteriorring(String pckg) throws SQLException {
Map<Integer, Integer> dbexpected = hanaExpectationsFactory.getNumInteriorRing();
String hql = format(
"SELECT id, numinteriorring(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Polygon') and srid(geom) = %d",
pckg,
"SELECT id, numinteriorring(geom) FROM %s where geometrytype(geom) in ('ST_Polygon') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -789,8 +789,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void numinteriorrings(String pckg) throws SQLException {
Map<Integer, Integer> dbexpected = hanaExpectationsFactory.getNumInteriorRings();
String hql = format(
"SELECT id, numinteriorrings(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Polygon') and srid(geom) = %d",
pckg,
"SELECT id, numinteriorrings(geom) FROM %s where geometrytype(geom) in ('ST_Polygon') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -809,8 +809,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void numpoints(String pckg) throws SQLException {
Map<Integer, Integer> dbexpected = hanaExpectationsFactory.getNumPoints();
String hql = format(
"SELECT id, numpoints(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
pckg,
"SELECT id, numpoints(geom) FROM %s where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -829,8 +829,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void orderingequals(String pckg) throws SQLException {
Map<Integer, Boolean> dbexpected = hanaExpectationsFactory.getOrderingEquals( expectationsFactory.getTestPolygon() );
String hql = format(
"SELECT id, orderingequals(geom, :filter) FROM org.hibernate.spatial.integration.%s.GeomEntity where orderingequals(geom, :filter) = true and srid(geom) = %d",
pckg,
"SELECT id, orderingequals(geom, :filter) FROM %s where orderingequals(geom, :filter) = true and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@ -850,8 +850,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void perimeter(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getPerimeter();
String hql = format(
"SELECT id, perimeter(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon') and srid(geom) = %d",
pckg,
"SELECT id, perimeter(geom) FROM %s where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -870,8 +870,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void pointonsurface(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getPointOnSurface();
String hql = format(
"SELECT id, pointonsurface(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon') and srid(geom) = %d",
pckg,
"SELECT id, pointonsurface(geom) FROM %s where geometrytype(geom) in ('ST_Polygon', 'ST_MultiPolygon') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -890,8 +890,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void pointn(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getPointN( 1 );
String hql = format(
"SELECT id, pointn(geom, :n) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
pckg,
"SELECT id, pointn(geom, :n) FROM %s where geometrytype(geom) in ('ST_LineString') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
Map<String, Object> params = createQueryParams( "n", 1 );
@ -913,8 +913,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void snaptogrid(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getSnapToGrid();
String hql = format(
"SELECT id, snaptogrid(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, snaptogrid(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -932,8 +932,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void startpoint(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getStartPoint();
String hql = format(
"SELECT id, startpoint(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g where geometrytype(geom) = 'ST_LineString'",
pckg
"SELECT id, startpoint(geom) FROM %s g where geometrytype(geom) = 'ST_LineString'",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -951,8 +951,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void unionaggr(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getUnionAggr();
String hql = format(
"SELECT cast(count(g) as int), unionaggr(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity g",
pckg
"SELECT cast(count(g) as int), unionaggr(geom) FROM %s g",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -970,8 +970,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void x(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getX();
String hql = format(
"SELECT id, x(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
pckg,
"SELECT id, x(geom) FROM %s where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -990,8 +990,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void xmax(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getXMax();
String hql = format(
"SELECT id, xmax(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, xmax(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1009,8 +1009,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void xmin(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getXMin();
String hql = format(
"SELECT id, xmin(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, xmin(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1028,8 +1028,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void y(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getY();
String hql = format(
"SELECT id, y(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
pckg,
"SELECT id, y(geom) FROM %s where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -1048,8 +1048,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void ymax(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getYMax();
String hql = format(
"SELECT id, ymax(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, ymax(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1067,8 +1067,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void ymin(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getYMin();
String hql = format(
"SELECT id, ymin(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, ymin(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1086,8 +1086,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void z(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getZ();
String hql = format(
"SELECT id, z(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
pckg,
"SELECT id, z(geom) FROM %s where geometrytype(geom) in ('ST_Point') and srid(geom) = %d",
entityName( pckg ),
expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
@ -1106,8 +1106,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void zmax(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getZMax();
String hql = format(
"SELECT id, zmax(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, zmax(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1125,8 +1125,8 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void zmin(String pckg) throws SQLException {
Map<Integer, Double> dbexpected = hanaExpectationsFactory.getZMin();
String hql = format(
"SELECT id, zmin(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
pckg, expectationsFactory.getTestSrid()
"SELECT id, zmin(geom) FROM %s where srid(geom) = %d",
entityName( pckg ), expectationsFactory.getTestSrid()
);
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
}
@ -1144,16 +1144,16 @@ public class TestHANASpatialFunctions extends TestSpatialFunctions {
public void nestedfunction(String pckg) throws SQLException {
Map<Integer, Geometry> dbexpected = hanaExpectationsFactory.getNestedFunctionInner( expectationsFactory.getTestPolygon() );
String hql = format(
"SELECT id, geom FROM org.hibernate.spatial.integration.%s.GeomEntity g where dwithin(geom, srid(:filter, 0), 1) = true",
pckg
"SELECT id, geom FROM %s g where dwithin(geom, srid(:filter, 0), 1) = true",
entityName( pckg )
);
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
dbexpected = hanaExpectationsFactory.getNestedFunctionOuter( expectationsFactory.getTestPolygon() );
hql = format(
"SELECT id, geom FROM org.hibernate.spatial.integration.%s.GeomEntity g where dwithin(:filter, srid(geom, 0), 1) = true",
pckg
"SELECT id, geom FROM %s g where dwithin(:filter, srid(geom, 0), 1) = true",
entityName( pckg )
);
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
}

View File

@ -29,7 +29,8 @@ import org.hibernate.spatial.HSMessageLogger;
import org.jboss.logging.Logger;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp2.BasicDataSource;
import org.geolatte.geom.Geometry;
import org.geolatte.geom.codec.Wkt;
import org.geolatte.geom.codec.WktDecodeException;

View File

@ -28,6 +28,7 @@ public class DB2DatabaseCleaner implements DatabaseCleaner {
+ "'SYSIBMADM',"
+ "'SYSPUBLIC',"
+ "'SYSSTAT',"
+ "'DB2GSE',"
+ "'SYSTOOLS'";
private final List<String> ignoredTables = new ArrayList<>();

View File

@ -31,7 +31,8 @@ public class PostgreSQLDatabaseCleaner implements DatabaseCleaner {
@Override
public boolean isApplicable(Connection connection) {
try {
return connection.getMetaData().getDatabaseProductName().startsWith( "PostgreSQL" );
return connection.getMetaData().getDatabaseProductName().startsWith( "PostgreSQL" )
&& isPostgresql( connection );
}
catch (SQLException e) {
throw new RuntimeException( "Could not resolve the database metadata!", e );
@ -88,7 +89,7 @@ public class PostgreSQLDatabaseCleaner implements DatabaseCleaner {
Map<String, List<String>> schemaExtensions = new HashMap<>();
try (Statement s2 = c.createStatement()) {
rs = s2.executeQuery(
"SELECT ns.nspname, 'CREATE EXTENSION ' || e.extname || ' SCHEMA \"' || ns.nspname || '\" VERSION ' || e.extversion FROM pg_extension e JOIN pg_catalog.pg_namespace ns ON e.extnamespace = ns.oid WHERE e.extname <> 'plpgsql'"
"SELECT ns.nspname, 'CREATE EXTENSION ' || e.extname || ' SCHEMA \"' || ns.nspname || '\"' FROM pg_extension e JOIN pg_catalog.pg_namespace ns ON e.extnamespace = ns.oid WHERE e.extname <> 'plpgsql'"
);
while ( rs.next() ) {
schemaExtensions.computeIfAbsent( rs.getString( 1 ), k -> new ArrayList<>() )
@ -211,4 +212,19 @@ public class PostgreSQLDatabaseCleaner implements DatabaseCleaner {
}
}
// We need this check to differentiate between Postgresql and Cockroachdb
private boolean isPostgresql(Connection connection) {
try (Statement stmt = connection.createStatement()) {
ResultSet rs = stmt.executeQuery( "select version() " );
while ( rs.next() ) {
String version = rs.getString( 1 );
return version.contains( "PostgreSQL" );
}
}
catch (SQLException e) {
throw new RuntimeException( e );
}
return false;
}
}