Merge remote-tracking branch 'upstream/master' into wip/6.0
This commit is contained in:
commit
283c3fefb5
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* 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>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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>.
|
||||||
|
*/
|
||||||
|
jdbcDependency 'org.postgresql:postgresql:42.2.8'
|
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# 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>.
|
||||||
|
#
|
||||||
|
|
||||||
|
hibernate.dialect org.hibernate.dialect.CockroachDB192Dialect
|
||||||
|
hibernate.connection.driver_class org.postgresql.Driver
|
||||||
|
hibernate.connection.url jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable
|
||||||
|
hibernate.connection.username root
|
||||||
|
hibernate.connection.password
|
||||||
|
|
||||||
|
hibernate.connection.pool_size 5
|
||||||
|
|
||||||
|
hibernate.show_sql false
|
||||||
|
hibernate.format_sql true
|
||||||
|
|
||||||
|
hibernate.max_fetch_depth 5
|
||||||
|
|
||||||
|
hibernate.cache.region_prefix hibernate.test
|
||||||
|
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||||
|
|
||||||
|
hibernate.service.allow_crawling=false
|
||||||
|
hibernate.session.events.log=true
|
|
@ -64,6 +64,7 @@ dependencies {
|
||||||
testRuntime( libraries.mariadb )
|
testRuntime( libraries.mariadb )
|
||||||
testRuntime( libraries.mssql )
|
testRuntime( libraries.mssql )
|
||||||
testRuntime( libraries.hana )
|
testRuntime( libraries.hana )
|
||||||
|
testRuntime( libraries.cockroachdb )
|
||||||
|
|
||||||
testCompile( project( ':hibernate-jcache' ) )
|
testCompile( project( ':hibernate-jcache' ) )
|
||||||
testRuntime( libraries.ehcache3 )
|
testRuntime( libraries.ehcache3 )
|
||||||
|
|
|
@ -24,6 +24,7 @@ import javax.persistence.TypedQuery;
|
||||||
import org.hibernate.CacheMode;
|
import org.hibernate.CacheMode;
|
||||||
import org.hibernate.ScrollableResults;
|
import org.hibernate.ScrollableResults;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
|
@ -1296,6 +1297,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/26710")
|
||||||
public void test_hql_sqrt_function_example() {
|
public void test_hql_sqrt_function_example() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-sqrt-function-example[]
|
//tag::hql-sqrt-function-example[]
|
||||||
|
|
|
@ -9,16 +9,13 @@ package org.hibernate.userguide.locking;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.annotations.OptimisticLock;
|
import org.hibernate.annotations.OptimisticLock;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +31,7 @@ public class OptimisticLockTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails at SERIALIZABLE isolation")
|
||||||
public void test() {
|
public void test() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
Phone phone = new Phone();
|
Phone phone = new Phone();
|
||||||
|
|
|
@ -13,13 +13,9 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.persistence.Lob;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.engine.jdbc.NClobProxy;
|
import org.hibernate.engine.jdbc.NClobProxy;
|
||||||
|
@ -37,7 +38,8 @@ import static org.junit.Assert.fail;
|
||||||
value = {
|
value = {
|
||||||
PostgreSQL81Dialect.class,
|
PostgreSQL81Dialect.class,
|
||||||
MySQL5Dialect.class,
|
MySQL5Dialect.class,
|
||||||
AbstractHANADialect.class
|
AbstractHANADialect.class,
|
||||||
|
CockroachDialect.class
|
||||||
},
|
},
|
||||||
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
|
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
|
||||||
)
|
)
|
||||||
|
|
|
@ -122,7 +122,15 @@ ext {
|
||||||
'jdbc.user' : 'VLAD',
|
'jdbc.user' : 'VLAD',
|
||||||
'jdbc.pass' : 'V1ad_test',
|
'jdbc.pass' : 'V1ad_test',
|
||||||
'jdbc.url' : 'jdbc:sap://localhost:39015/'
|
'jdbc.url' : 'jdbc:sap://localhost:39015/'
|
||||||
]
|
],
|
||||||
|
cockroachdb : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.CockroachDB192Dialect',
|
||||||
|
// CockroachDB uses the same pgwire protocol as PostgreSQL, so the driver is the same.
|
||||||
|
'jdbc.driver': 'org.postgresql.Driver',
|
||||||
|
'jdbc.user' : 'root',
|
||||||
|
'jdbc.pass' : '',
|
||||||
|
'jdbc.url' : 'jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable'
|
||||||
|
],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ dependencies {
|
||||||
testRuntime( libraries.mssql )
|
testRuntime( libraries.mssql )
|
||||||
testRuntime( libraries.informix )
|
testRuntime( libraries.informix )
|
||||||
testRuntime( libraries.hana )
|
testRuntime( libraries.hana )
|
||||||
|
testRuntime( libraries.cockroachdb )
|
||||||
|
|
||||||
if ( db.equalsIgnoreCase( 'oracle' ) ) {
|
if ( db.equalsIgnoreCase( 'oracle' ) ) {
|
||||||
testRuntime( libraries.oracle ) {
|
testRuntime( libraries.oracle ) {
|
||||||
|
|
|
@ -127,6 +127,7 @@ ext {
|
||||||
postgresql: 'org.postgresql:postgresql:42.2.2',
|
postgresql: 'org.postgresql:postgresql:42.2.2',
|
||||||
mysql: 'mysql:mysql-connector-java:8.0.17',
|
mysql: 'mysql:mysql-connector-java:8.0.17',
|
||||||
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',
|
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',
|
||||||
|
cockroachdb: 'org.postgresql:postgresql:42.2.8',
|
||||||
|
|
||||||
oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1',
|
oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1',
|
||||||
mssql: 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8',
|
mssql: 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8',
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.boot.jaxb.Origin;
|
||||||
import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgHibernateConfiguration;
|
import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgHibernateConfiguration;
|
||||||
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
|
import org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.config.ConfigurationException;
|
import org.hibernate.internal.util.config.ConfigurationException;
|
||||||
import org.hibernate.internal.util.xml.XsdException;
|
import org.hibernate.internal.util.xml.XsdException;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
@ -136,7 +137,7 @@ public class JaxbCfgProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNamespaced(StartElement startElement) {
|
private boolean isNamespaced(StartElement startElement) {
|
||||||
return ! "".equals( startElement.getName().getNamespaceURI() );
|
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Schema schema;
|
private Schema schema;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.boot.jaxb.spi.Binder;
|
||||||
import org.hibernate.boot.jaxb.spi.Binding;
|
import org.hibernate.boot.jaxb.spi.Binding;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
|
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +153,7 @@ public abstract class AbstractBinder implements Binder {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
protected static boolean hasNamespace(StartElement startElement) {
|
protected static boolean hasNamespace(StartElement startElement) {
|
||||||
return ! "".equals( startElement.getName().getNamespaceURI() );
|
return StringHelper.isNotEmpty( startElement.getName().getNamespaceURI() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -20,6 +20,7 @@ import javax.xml.stream.events.XMLEvent;
|
||||||
import javax.xml.stream.util.EventReaderDelegate;
|
import javax.xml.stream.util.EventReaderDelegate;
|
||||||
|
|
||||||
import org.hibernate.boot.xsd.MappingXsdSupport;
|
import org.hibernate.boot.xsd.MappingXsdSupport;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A StAX EventReader for {@code hbm.xml} files to add namespaces in documents
|
* A StAX EventReader for {@code hbm.xml} files to add namespaces in documents
|
||||||
|
@ -66,7 +67,7 @@ public class HbmEventReader extends EventReaderDelegate {
|
||||||
private StartElement applyNamespace(StartElement startElement) {
|
private StartElement applyNamespace(StartElement startElement) {
|
||||||
final List<Namespace> targetNamespaces = new ArrayList<>();
|
final List<Namespace> targetNamespaces = new ArrayList<>();
|
||||||
|
|
||||||
if ( "".equals( startElement.getName().getNamespaceURI() ) ) {
|
if ( StringHelper.isEmpty( startElement.getName().getNamespaceURI() ) ) {
|
||||||
// add the default namespace mapping
|
// add the default namespace mapping
|
||||||
targetNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.hbmXsd().getNamespaceUri() ) );
|
targetNamespaces.add( xmlEventFactory.createNamespace( MappingXsdSupport.INSTANCE.hbmXsd().getNamespaceUri() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.boot.model.naming;
|
package org.hibernate.boot.model.naming;
|
||||||
|
|
||||||
import org.hibernate.boot.model.source.spi.AttributePath;
|
import org.hibernate.boot.model.source.spi.AttributePath;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ImplicitNamingStrategy implementation which uses full composite paths
|
* An ImplicitNamingStrategy implementation which uses full composite paths
|
||||||
|
@ -31,7 +32,7 @@ public class ImplicitNamingStrategyComponentPathImpl extends ImplicitNamingStrat
|
||||||
public static void process(AttributePath attributePath, StringBuilder sb) {
|
public static void process(AttributePath attributePath, StringBuilder sb) {
|
||||||
if ( attributePath.getParent() != null ) {
|
if ( attributePath.getParent() != null ) {
|
||||||
process( attributePath.getParent(), sb );
|
process( attributePath.getParent(), sb );
|
||||||
if ( !"".equals( attributePath.getParent().getProperty() ) ) {
|
if ( StringHelper.isNotEmpty( attributePath.getParent().getProperty() ) ) {
|
||||||
sb.append( '_' );
|
sb.append( '_' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, rootMetadataBuildingContext );
|
AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, rootMetadataBuildingContext );
|
||||||
|
AnnotationBinder.bindFetchProfilesForClass( clazz, rootMetadataBuildingContext );
|
||||||
processedEntityNames.add( clazz.getName() );
|
processedEntityNames.add( clazz.getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +302,9 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessEntityHierarchies() {
|
public void postProcessEntityHierarchies() {
|
||||||
|
for ( String annotatedPackage : annotatedPackages ) {
|
||||||
|
AnnotationBinder.bindFetchProfilesForPackage( annotatedPackage, rootMetadataBuildingContext );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class NamedQueryBinder {
|
||||||
for ( Object content : namedQueryBinding.getContent() ) {
|
for ( Object content : namedQueryBinding.getContent() ) {
|
||||||
if ( content instanceof String ) {
|
if ( content instanceof String ) {
|
||||||
final String hqlString = StringHelper.nullIfEmpty( ( (String) content ).trim() );
|
final String hqlString = StringHelper.nullIfEmpty( ( (String) content ).trim() );
|
||||||
if ( !StringHelper.isEmpty( hqlString ) ) {
|
if ( StringHelper.isNotEmpty( hqlString ) ) {
|
||||||
queryBuilder.setHqlString( hqlString );
|
queryBuilder.setHqlString( hqlString );
|
||||||
foundQuery = true;
|
foundQuery = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,6 @@ public final class AnnotationBinder {
|
||||||
bindQueries( pckg, context );
|
bindQueries( pckg, context );
|
||||||
bindFilterDefs( pckg, context );
|
bindFilterDefs( pckg, context );
|
||||||
bindTypeDefs( pckg, context );
|
bindTypeDefs( pckg, context );
|
||||||
bindFetchProfiles( pckg, context );
|
|
||||||
BinderHelper.bindAnyMetaDefs( pckg, context );
|
BinderHelper.bindAnyMetaDefs( pckg, context );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -619,7 +618,6 @@ public final class AnnotationBinder {
|
||||||
bindQueries( clazzToProcess, context );
|
bindQueries( clazzToProcess, context );
|
||||||
bindFilterDefs( clazzToProcess, context );
|
bindFilterDefs( clazzToProcess, context );
|
||||||
bindTypeDefs( clazzToProcess, context );
|
bindTypeDefs( clazzToProcess, context );
|
||||||
bindFetchProfiles( clazzToProcess, context );
|
|
||||||
BinderHelper.bindAnyMetaDefs( clazzToProcess, context );
|
BinderHelper.bindAnyMetaDefs( clazzToProcess, context );
|
||||||
|
|
||||||
String schema = "";
|
String schema = "";
|
||||||
|
@ -1501,6 +1499,27 @@ public final class AnnotationBinder {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void bindFetchProfilesForClass(XClass clazzToProcess, MetadataBuildingContext context) {
|
||||||
|
bindFetchProfiles( clazzToProcess, context );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void bindFetchProfilesForPackage(String packageName, MetadataBuildingContext context) {
|
||||||
|
XPackage pckg;
|
||||||
|
try {
|
||||||
|
pckg = context.getBootstrapContext().getReflectionManager().packageForName( packageName );
|
||||||
|
}
|
||||||
|
catch (ClassLoadingException e) {
|
||||||
|
LOG.packageNotFound( packageName );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch ( ClassNotFoundException cnf ) {
|
||||||
|
LOG.packageNotFound( packageName );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bindFetchProfiles( pckg, context );
|
||||||
|
}
|
||||||
|
|
||||||
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, MetadataBuildingContext context) {
|
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, MetadataBuildingContext context) {
|
||||||
FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class );
|
FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class );
|
||||||
FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );
|
FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );
|
||||||
|
|
|
@ -563,7 +563,7 @@ public class Ejb3Column {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String columnName;
|
final String columnName;
|
||||||
if ( "".equals( col.name() ) ) {
|
if ( col.name() != null && col.name().isEmpty() ) {
|
||||||
columnName = null;
|
columnName = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -366,7 +366,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name;
|
final String name;
|
||||||
if ( "".equals( colName ) ) {
|
if ( colName != null && colName.isEmpty() ) {
|
||||||
name = normalizer.normalizeIdentifierQuotingAsString( defaultName );
|
name = normalizer.normalizeIdentifierQuotingAsString( defaultName );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ public abstract class CollectionBinder {
|
||||||
ConstraintMode foreignKeyValue = joinTableAnn.foreignKey().value();
|
ConstraintMode foreignKeyValue = joinTableAnn.foreignKey().value();
|
||||||
if ( joinTableAnn.joinColumns().length != 0 ) {
|
if ( joinTableAnn.joinColumns().length != 0 ) {
|
||||||
final JoinColumn joinColumnAnn = joinTableAnn.joinColumns()[0];
|
final JoinColumn joinColumnAnn = joinTableAnn.joinColumns()[0];
|
||||||
if ( "".equals( foreignKeyName ) ) {
|
if ( foreignKeyName != null && foreignKeyName.isEmpty() ) {
|
||||||
foreignKeyName = joinColumnAnn.foreignKey().name();
|
foreignKeyName = joinColumnAnn.foreignKey().name();
|
||||||
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
|
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
|
||||||
}
|
}
|
||||||
|
@ -1447,7 +1447,7 @@ public abstract class CollectionBinder {
|
||||||
ConstraintMode foreignKeyValue = joinTableAnn.inverseForeignKey().value();
|
ConstraintMode foreignKeyValue = joinTableAnn.inverseForeignKey().value();
|
||||||
if ( joinTableAnn.inverseJoinColumns().length != 0 ) {
|
if ( joinTableAnn.inverseJoinColumns().length != 0 ) {
|
||||||
final JoinColumn joinColumnAnn = joinTableAnn.inverseJoinColumns()[0];
|
final JoinColumn joinColumnAnn = joinTableAnn.inverseJoinColumns()[0];
|
||||||
if ( "".equals( foreignKeyName ) ) {
|
if ( foreignKeyName != null && foreignKeyName.isEmpty() ) {
|
||||||
foreignKeyName = joinColumnAnn.foreignKey().name();
|
foreignKeyName = joinColumnAnn.foreignKey().name();
|
||||||
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
|
foreignKeyDefinition = joinColumnAnn.foreignKey().foreignKeyDefinition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,13 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import org.hibernate.*;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.LockMode;
|
||||||
|
import org.hibernate.LockOptions;
|
||||||
|
import org.hibernate.MappingException;
|
||||||
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
|
import org.hibernate.NullPrecedence;
|
||||||
|
import org.hibernate.ScrollMode;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||||
import org.hibernate.boot.model.relational.Sequence;
|
import org.hibernate.boot.model.relational.Sequence;
|
||||||
|
@ -1585,7 +1591,7 @@ public abstract class Dialect implements ConversionContext {
|
||||||
return new InlineStrategy( this );
|
return new InlineStrategy( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PersistentTableStrategy(
|
return new PersistentTableStrategy(
|
||||||
new IdTable( entityDescriptor, name -> name ),
|
new IdTable( entityDescriptor, name -> name ),
|
||||||
AfterUseAction.CLEAN,
|
AfterUseAction.CLEAN,
|
||||||
|
@ -1784,11 +1790,11 @@ public abstract class Dialect implements ConversionContext {
|
||||||
* Build an instance of a {@link SQLExceptionConversionDelegate} for
|
* Build an instance of a {@link SQLExceptionConversionDelegate} for
|
||||||
* interpreting dialect-specific error or SQLState codes.
|
* interpreting dialect-specific error or SQLState codes.
|
||||||
* <p/>
|
* <p/>
|
||||||
* When {@link #buildSQLExceptionConverter} returns null, the default
|
* When {@link #buildSQLExceptionConverter} returns null, the default
|
||||||
* {@link SQLExceptionConverter} is used to interpret SQLState and
|
* {@link SQLExceptionConverter} is used to interpret SQLState and
|
||||||
* error codes. If this method is overridden to return a non-null value,
|
* error codes. If this method is overridden to return a non-null value,
|
||||||
* the default {@link SQLExceptionConverter} will use the returned
|
* the default {@link SQLExceptionConverter} will use the returned
|
||||||
* {@link SQLExceptionConversionDelegate} in addition to the following
|
* {@link SQLExceptionConversionDelegate} in addition to the following
|
||||||
* standard delegates:
|
* standard delegates:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>a "static" delegate based on the JDBC 4 defined SQLException hierarchy;</li>
|
* <li>a "static" delegate based on the JDBC 4 defined SQLException hierarchy;</li>
|
||||||
|
@ -2941,7 +2947,7 @@ public abstract class Dialect implements ConversionContext {
|
||||||
*/
|
*/
|
||||||
public String getQueryHintString(String query, List<String> hintList) {
|
public String getQueryHintString(String query, List<String> hintList) {
|
||||||
final String hints = String.join( ", ", hintList );
|
final String hints = String.join( ", ", hintList );
|
||||||
return StringHelper.isEmpty(hints) ? query : getQueryHintString(query, hints);
|
return StringHelper.isEmpty( hints) ? query : getQueryHintString( query, hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3010,7 +3016,7 @@ public abstract class Dialect implements ConversionContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
||||||
// nohing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.dialect.identity;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
|
public class CockroachDB1920IdentityColumnSupport extends IdentityColumnSupportImpl {
|
||||||
|
@Override
|
||||||
|
public boolean supportsIdentityColumns() {
|
||||||
|
// Full support requires setting the sql.defaults.serial_normalization=sql_sequence in CockroachDB.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// CockroachDB does not create a sequence for id columns
|
||||||
|
public String getIdentitySelectString(String table, String column, int type) {
|
||||||
|
return "select 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentityColumnString(int type) {
|
||||||
|
return type == Types.SMALLINT ?
|
||||||
|
"serial4 not null" :
|
||||||
|
"serial8 not null";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasDataTypeInIdentityColumn() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1120,9 +1120,6 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
this.statementInspector = sessionFactoryOptions.getStatementInspector();
|
this.statementInspector = sessionFactoryOptions.getStatementInspector();
|
||||||
this.connectionHandlingMode = sessionFactoryOptions.getPhysicalConnectionHandlingMode();
|
this.connectionHandlingMode = sessionFactoryOptions.getPhysicalConnectionHandlingMode();
|
||||||
this.autoClose = sessionFactoryOptions.isAutoCloseSessionEnabled();
|
this.autoClose = sessionFactoryOptions.isAutoCloseSessionEnabled();
|
||||||
this.flushMode = sessionFactoryOptions.isFlushBeforeCompletionEnabled()
|
|
||||||
? FlushMode.AUTO
|
|
||||||
: FlushMode.MANUAL;
|
|
||||||
|
|
||||||
final CurrentTenantIdentifierResolver currentTenantIdentifierResolver = sessionFactory.getCurrentTenantIdentifierResolver();
|
final CurrentTenantIdentifierResolver currentTenantIdentifierResolver = sessionFactory.getCurrentTenantIdentifierResolver();
|
||||||
if ( currentTenantIdentifierResolver != null ) {
|
if ( currentTenantIdentifierResolver != null ) {
|
||||||
|
|
|
@ -223,14 +223,17 @@ public class SessionImpl
|
||||||
// NOTE : pulse() already handles auto-join-ability correctly
|
// NOTE : pulse() already handles auto-join-ability correctly
|
||||||
getTransactionCoordinator().pulse();
|
getTransactionCoordinator().pulse();
|
||||||
|
|
||||||
final FlushMode initialMode;
|
// do not override explicitly set flush mode ( SessionBuilder#flushMode() )
|
||||||
if ( this.properties == null ) {
|
if ( getHibernateFlushMode() == null ) {
|
||||||
initialMode = fastSessionServices.initialSessionFlushMode;
|
final FlushMode initialMode;
|
||||||
|
if ( this.properties == null ) {
|
||||||
|
initialMode = fastSessionServices.initialSessionFlushMode;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
initialMode = ConfigurationHelper.getFlushMode( getSessionProperty( AvailableSettings.FLUSH_MODE ), FlushMode.AUTO );
|
||||||
|
}
|
||||||
|
getSession().setHibernateFlushMode( initialMode );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
initialMode = ConfigurationHelper.getFlushMode( getSessionProperty( AvailableSettings.FLUSH_MODE ), FlushMode.AUTO );
|
|
||||||
}
|
|
||||||
getSession().setHibernateFlushMode( initialMode );
|
|
||||||
|
|
||||||
if ( log.isTraceEnabled() ) {
|
if ( log.isTraceEnabled() ) {
|
||||||
log.tracef( "Opened Session [%s] at timestamp: %s", getSessionIdentifier(), getTimestamp() );
|
log.tracef( "Opened Session [%s] at timestamp: %s", getSessionIdentifier(), getTimestamp() );
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ( !"".equals( extraPhysycalTableTypesConfig.trim() ) ) {
|
if ( ! StringHelper.isEmptyOrWhiteSpace( extraPhysycalTableTypesConfig ) ) {
|
||||||
this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
|
this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
|
||||||
",;",
|
",;",
|
||||||
extraPhysycalTableTypesConfig,
|
extraPhysycalTableTypesConfig,
|
||||||
|
|
|
@ -479,7 +479,7 @@ public class SchemaCreatorImpl implements SchemaCreator {
|
||||||
|
|
||||||
for ( String currentFile : importFiles.split( "," ) ) {
|
for ( String currentFile : importFiles.split( "," ) ) {
|
||||||
final String resourceName = currentFile.trim();
|
final String resourceName = currentFile.trim();
|
||||||
if ( "".equals( resourceName ) ) {
|
if ( resourceName != null && resourceName.isEmpty() ) {
|
||||||
//skip empty resource names
|
//skip empty resource names
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class ClobTypeDescriptor extends AbstractTypeDescriptor<Clob> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( CharacterStream.class.isAssignableFrom( type ) ) {
|
if ( CharacterStream.class.isAssignableFrom( type ) ) {
|
||||||
if ( ClobImplementer.class.isInstance( value ) ) {
|
if (value instanceof ClobImplementer) {
|
||||||
// if the incoming Clob is a wrapper, just pass along its CharacterStream
|
// if the incoming Clob is a wrapper, just pass along its CharacterStream
|
||||||
return (X) ( (ClobImplementer) value ).getUnderlyingStream();
|
return (X) ( (ClobImplementer) value ).getUnderlyingStream();
|
||||||
}
|
}
|
||||||
|
@ -107,11 +107,21 @@ public class ClobTypeDescriptor extends AbstractTypeDescriptor<Clob> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Clob.class.isAssignableFrom( type )) {
|
else if (Clob.class.isAssignableFrom( type )) {
|
||||||
final Clob clob = WrappedClob.class.isInstance( value )
|
final Clob clob = value instanceof WrappedClob
|
||||||
? ( (WrappedClob) value ).getWrappedClob()
|
? ( (WrappedClob) value ).getWrappedClob()
|
||||||
: value;
|
: value;
|
||||||
return (X) clob;
|
return (X) clob;
|
||||||
}
|
}
|
||||||
|
else if ( String.class.isAssignableFrom( type ) ) {
|
||||||
|
if (value instanceof ClobImplementer) {
|
||||||
|
// if the incoming Clob is a wrapper, just get the underlying String.
|
||||||
|
return (X) ( (ClobImplementer) value ).getUnderlyingStream().asString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// otherwise we need to extract the String.
|
||||||
|
return (X) DataHelper.extractString( value.getCharacterStream() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( SQLException e ) {
|
catch ( SQLException e ) {
|
||||||
throw new HibernateException( "Unable to access clob stream", e );
|
throw new HibernateException( "Unable to access clob stream", e );
|
||||||
|
@ -137,6 +147,9 @@ public class ClobTypeDescriptor extends AbstractTypeDescriptor<Clob> {
|
||||||
Reader reader = (Reader) value;
|
Reader reader = (Reader) value;
|
||||||
return options.getLobCreator().createClob( DataHelper.extractString( reader ) );
|
return options.getLobCreator().createClob( DataHelper.extractString( reader ) );
|
||||||
}
|
}
|
||||||
|
else if ( String.class.isAssignableFrom( value.getClass() ) ) {
|
||||||
|
return options.getLobCreator().createClob( (String) value );
|
||||||
|
}
|
||||||
|
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,9 @@ import org.hibernate.Transaction;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -60,6 +63,7 @@ public class ReadWriteCacheTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "CockroachDB uses SERIALIZABLE isolation, and does not support this")
|
||||||
public void testDelete() throws InterruptedException {
|
public void testDelete() throws InterruptedException {
|
||||||
bookId = 1L;
|
bookId = 1L;
|
||||||
|
|
||||||
|
@ -136,6 +140,7 @@ public class ReadWriteCacheTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "CockroachDB uses SERIALIZABLE isolation, and does not support this")
|
||||||
public void testUpdate() throws InterruptedException {
|
public void testUpdate() throws InterruptedException {
|
||||||
bookId = 4L;
|
bookId = 4L;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class BatchSortingTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "GeoCountry")
|
||||||
public static class GeoCountry {
|
public static class GeoCountry {
|
||||||
|
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -112,7 +112,7 @@ public class BatchSortingTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "GeoDistrict")
|
||||||
public static class GeoDistrict {
|
public static class GeoDistrict {
|
||||||
|
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -161,7 +161,7 @@ public class BatchSortingTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "GeoDistrictDetail")
|
||||||
public static class GeoDistrictDetail {
|
public static class GeoDistrictDetail {
|
||||||
|
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -178,7 +178,7 @@ public class BatchSortingTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "GeoNation")
|
||||||
public static class GeoNation {
|
public static class GeoNation {
|
||||||
|
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.hibernate.internal;
|
||||||
|
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
import org.junit.runners.Parameterized.Parameter;
|
||||||
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Michael Spahn
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-13974")
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
|
public class SessionBuilderFlushModeTest {
|
||||||
|
|
||||||
|
private static SessionFactory sessionFactory;
|
||||||
|
|
||||||
|
@Parameters
|
||||||
|
public static FlushMode[] parameters() {
|
||||||
|
return FlushMode.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parameter
|
||||||
|
public FlushMode flushMode;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() {
|
||||||
|
sessionFactory = new MetadataSources( new StandardServiceRegistryBuilder().build() ).buildMetadata().buildSessionFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDown() {
|
||||||
|
if ( sessionFactory != null ) {
|
||||||
|
sessionFactory.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFlushMode() {
|
||||||
|
try (final Session session = sessionFactory.withOptions().flushMode( flushMode ).openSession()) {
|
||||||
|
assertEquals( flushMode, session.getHibernateFlushMode() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
import javax.persistence.criteria.SetJoin;
|
import javax.persistence.criteria.SetJoin;
|
||||||
import javax.persistence.metamodel.EntityType;
|
import javax.persistence.metamodel.EntityType;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.jpa.test.metamodel.Address;
|
import org.hibernate.jpa.test.metamodel.Address;
|
||||||
|
@ -40,6 +40,7 @@ import org.hibernate.query.sqm.tree.predicate.SqmComparisonPredicate;
|
||||||
|
|
||||||
import org.hibernate.testing.FailureExpected;
|
import org.hibernate.testing.FailureExpected;
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -232,6 +233,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, strictMatching = true)
|
||||||
public void testDateTimeFunctions() {
|
public void testDateTimeFunctions() {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.criteria.basic;
|
package org.hibernate.jpa.test.criteria.basic;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
@ -15,6 +13,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Path;
|
import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Oracle12cDialect;
|
import org.hibernate.dialect.Oracle12cDialect;
|
||||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||||
|
@ -29,6 +28,9 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the various predicates.
|
* Test the various predicates.
|
||||||
*
|
*
|
||||||
|
@ -246,6 +248,7 @@ public class PredicateTest extends AbstractMetamodelSpecificTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-5803" )
|
@TestForIssue( jiraKey = "HHH-5803" )
|
||||||
|
@SkipForDialect( value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943")
|
||||||
public void testQuotientConversion() {
|
public void testQuotientConversion() {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
|
@ -14,10 +14,12 @@ import javax.persistence.Table;
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
import org.hibernate.testing.SkipForDialects;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -60,6 +62,12 @@ public class CriteriaLiteralWithSingleQuoteTest extends BaseEntityManagerFunctio
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialects(
|
||||||
|
value = {
|
||||||
|
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement"),
|
||||||
|
@SkipForDialect( value = CockroachDialect.class, comment = "CockroachDB does not support literals in group by statement")
|
||||||
|
}
|
||||||
|
)
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement")
|
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement")
|
||||||
public void testLiteralProjectionAndGroupBy() throws Exception {
|
public void testLiteralProjectionAndGroupBy() throws Exception {
|
||||||
doInJPA(
|
doInJPA(
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.jpa.test.graphs;
|
package org.hibernate.jpa.test.graphs;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
|
@ -17,6 +18,7 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
@ -62,110 +64,119 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
doInJPA(
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
this::entityManagerFactory, entityManager -> {
|
// Create the model twice, with different IDs,
|
||||||
AEntity a1 = new AEntity();
|
// because we also need to test what happens when multiple results are loaded by a query.
|
||||||
a1.setId( 1 );
|
for ( int offset : new int[]{ 0, 10000 } ) {
|
||||||
a1.setLabel( "A1" );
|
AEntity a1 = new AEntity();
|
||||||
|
a1.setId( offset + 1 );
|
||||||
|
a1.setLabel( "A1" );
|
||||||
|
|
||||||
AEntity a2 = new AEntity();
|
AEntity a2 = new AEntity();
|
||||||
a2.setId( 2 );
|
a2.setId( offset + 2 );
|
||||||
a2.setLabel( "A2" );
|
a2.setLabel( "A2" );
|
||||||
|
|
||||||
entityManager.persist( a1 );
|
entityManager.persist( a1 );
|
||||||
entityManager.persist( a2 );
|
entityManager.persist( a2 );
|
||||||
|
|
||||||
BEntity b1 = new BEntity();
|
BEntity b1 = new BEntity();
|
||||||
b1.setId( 1 );
|
b1.setId( offset + 1 );
|
||||||
b1.setLabel( "B1" );
|
b1.setLabel( "B1" );
|
||||||
|
|
||||||
BEntity b2 = new BEntity();
|
BEntity b2 = new BEntity();
|
||||||
b2.setId( 2 );
|
b2.setId( offset + 2 );
|
||||||
b2.setLabel( "B2" );
|
b2.setLabel( "B2" );
|
||||||
|
|
||||||
entityManager.persist( b1 );
|
entityManager.persist( b1 );
|
||||||
entityManager.persist( b2 );
|
entityManager.persist( b2 );
|
||||||
|
|
||||||
EEntity e1 = new EEntity();
|
EEntity e1 = new EEntity();
|
||||||
e1.setId( 1 );
|
e1.setId( offset + 1 );
|
||||||
e1.setLabel( "E1" );
|
e1.setLabel( "E1" );
|
||||||
|
|
||||||
EEntity e2 = new EEntity();
|
EEntity e2 = new EEntity();
|
||||||
e2.setId( 2 );
|
e2.setId( offset + 2 );
|
||||||
e2.setLabel( "E2" );
|
e2.setLabel( "E2" );
|
||||||
|
|
||||||
EEntity e3 = new EEntity();
|
EEntity e3 = new EEntity();
|
||||||
e3.setId( 3 );
|
e3.setId( offset + 3 );
|
||||||
e3.setLabel( "E3" );
|
e3.setLabel( "E3" );
|
||||||
|
|
||||||
EEntity e4 = new EEntity();
|
EEntity e4 = new EEntity();
|
||||||
e4.setId( 4 );
|
e4.setId( offset + 4 );
|
||||||
e4.setLabel( "E4" );
|
e4.setLabel( "E4" );
|
||||||
|
|
||||||
entityManager.persist( e1 );
|
entityManager.persist( e1 );
|
||||||
entityManager.persist( e2 );
|
entityManager.persist( e2 );
|
||||||
entityManager.persist( e3 );
|
entityManager.persist( e3 );
|
||||||
entityManager.persist( e4 );
|
entityManager.persist( e4 );
|
||||||
|
|
||||||
DEntity d1 = new DEntity();
|
DEntity d1 = new DEntity();
|
||||||
d1.setId( 1 );
|
d1.setId( offset + 1 );
|
||||||
d1.setLabel( "D1" );
|
d1.setLabel( "D1" );
|
||||||
d1.setE( e1 );
|
d1.setE( e1 );
|
||||||
|
|
||||||
DEntity d2 = new DEntity();
|
DEntity d2 = new DEntity();
|
||||||
d2.setId( 2 );
|
d2.setId( offset + 2 );
|
||||||
d2.setLabel( "D2" );
|
d2.setLabel( "D2" );
|
||||||
d2.setE( e2 );
|
d2.setE( e2 );
|
||||||
|
|
||||||
CEntity c1 = new CEntity();
|
CEntity c1 = new CEntity();
|
||||||
c1.setId( 1 );
|
c1.setId( offset + 1 );
|
||||||
c1.setLabel( "C1" );
|
c1.setLabel( "C1" );
|
||||||
c1.setA( a1 );
|
c1.setA( a1 );
|
||||||
c1.setB( b1 );
|
c1.setB( b1 );
|
||||||
c1.addD( d1 );
|
c1.addD( d1 );
|
||||||
c1.addD( d2 );
|
c1.addD( d2 );
|
||||||
|
|
||||||
entityManager.persist( c1 );
|
entityManager.persist( c1 );
|
||||||
|
|
||||||
DEntity d3 = new DEntity();
|
DEntity d3 = new DEntity();
|
||||||
d3.setId( 3 );
|
d3.setId( offset + 3 );
|
||||||
d3.setLabel( "D3" );
|
d3.setLabel( "D3" );
|
||||||
d3.setE( e3 );
|
d3.setE( e3 );
|
||||||
|
|
||||||
DEntity d4 = new DEntity();
|
DEntity d4 = new DEntity();
|
||||||
d4.setId( 4 );
|
d4.setId( offset + 4 );
|
||||||
d4.setLabel( "D4" );
|
d4.setLabel( "D4" );
|
||||||
d4.setE( e4 );
|
d4.setE( e4 );
|
||||||
|
|
||||||
CEntity c2 = new CEntity();
|
CEntity c2 = new CEntity();
|
||||||
c2.setId( 2 );
|
c2.setId( offset + 2 );
|
||||||
c2.setLabel( "C2" );
|
c2.setLabel( "C2" );
|
||||||
c2.setA( a2 );
|
c2.setA( a2 );
|
||||||
c2.setB( b2 );
|
c2.setB( b2 );
|
||||||
c2.addD( d3 );
|
c2.addD( d3 );
|
||||||
c2.addD( d4 );
|
c2.addD( d4 );
|
||||||
|
|
||||||
entityManager.persist( c2 );
|
entityManager.persist( c2 );
|
||||||
|
|
||||||
CEntity c3 = new CEntity();
|
CEntity c3 = new CEntity();
|
||||||
c3.setId( 3 );
|
c3.setId( offset + 3 );
|
||||||
c3.setLabel( "C3" );
|
c3.setLabel( "C3" );
|
||||||
|
|
||||||
entityManager.persist( c3 );
|
entityManager.persist( c3 );
|
||||||
|
|
||||||
c1.setC( c2 );
|
CEntity c4 = new CEntity();
|
||||||
c2.setC( c3 );
|
c4.setId( offset + 4 );
|
||||||
|
c4.setLabel( "C4" );
|
||||||
|
|
||||||
int id = 5;
|
entityManager.persist( c4 );
|
||||||
for ( int i = 0; i < 10; i++ ) {
|
|
||||||
DEntity dn = new DEntity();
|
|
||||||
dn.setId( id++ );
|
|
||||||
dn.setLabel( "label" );
|
|
||||||
dn.setE( e3 );
|
|
||||||
entityManager.persist( dn );
|
|
||||||
}
|
|
||||||
|
|
||||||
} );
|
c1.setC( c2 );
|
||||||
|
c2.setC( c3 );
|
||||||
|
c1.setEagerC( c4 );
|
||||||
|
|
||||||
|
int id = 5;
|
||||||
|
for ( int i = 0; i < 10; i++ ) {
|
||||||
|
DEntity dn = new DEntity();
|
||||||
|
dn.setId( offset + id++ );
|
||||||
|
dn.setLabel( "label" );
|
||||||
|
dn.setE( e3 );
|
||||||
|
entityManager.persist( dn );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -186,7 +197,10 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertFalse( Hibernate.isInitialized( cEntity.getC() ) );
|
assertFalse( Hibernate.isInitialized( cEntity.getC() ) );
|
||||||
assertFalse( Hibernate.isInitialized( cEntity.getdList() ) );
|
assertFalse( Hibernate.isInitialized( cEntity.getdList() ) );
|
||||||
|
|
||||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
assertTrue( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
|
||||||
|
// 1 + 1 for the eager C
|
||||||
|
assertEquals( 2L, statistics.getPrepareStatementCount() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +231,12 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
// With LOAD semantic, attributes that are not mentioned in the graph are LAZY or EAGER,
|
||||||
|
// depending on the mapping.
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
|
||||||
|
// 1 + 1 for the eager C
|
||||||
|
assertEquals( 2L, statistics.getPrepareStatementCount() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +266,10 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
// With FETCH semantic, attributes that are not mentioned in the graph are LAZY,
|
||||||
|
// even if they were EAGER in the mapping.
|
||||||
|
assertFalse( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
|
||||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -272,10 +295,91 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
assertTrue( Hibernate.isInitialized( cEntity.getC().getA() ) );
|
assertTrue( Hibernate.isInitialized( cEntity.getC().getA() ) );
|
||||||
assertFalse( Hibernate.isInitialized( cEntity.getC().getC() ) );
|
assertFalse( Hibernate.isInitialized( cEntity.getC().getC() ) );
|
||||||
|
|
||||||
|
// With FETCH semantic, attributes that are not mentioned in the graph are LAZY,
|
||||||
|
// even if they were EAGER in the mapping.
|
||||||
|
assertFalse( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
|
||||||
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-14124")
|
||||||
|
public void testQueryByIdWithLoadGraphMultipleResults() {
|
||||||
|
Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics();
|
||||||
|
statistics.clear();
|
||||||
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
|
EntityGraph<CEntity> entityGraph = entityManager.createEntityGraph( CEntity.class );
|
||||||
|
entityGraph.addAttributeNodes( "a", "b" );
|
||||||
|
entityGraph.addSubgraph( "dList" ).addAttributeNodes( "e" );
|
||||||
|
|
||||||
|
TypedQuery<CEntity> query = entityManager.createQuery(
|
||||||
|
"select c from CEntity as c where c.id in :cid ",
|
||||||
|
CEntity.class
|
||||||
|
);
|
||||||
|
query.setHint( GraphSemantic.LOAD.getJpaHintName(), entityGraph );
|
||||||
|
query.setParameter( "cid", Arrays.asList( 1, 10001 ) );
|
||||||
|
|
||||||
|
List<CEntity> cEntityList = query.getResultList();
|
||||||
|
assertEquals( 2, cEntityList.size() );
|
||||||
|
|
||||||
|
for ( CEntity cEntity : cEntityList ) {
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getA() ) );
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getB() ) );
|
||||||
|
assertFalse( Hibernate.isInitialized( cEntity.getC() ) );
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getdList() ) );
|
||||||
|
cEntity.getdList().forEach( dEntity -> {
|
||||||
|
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
// With LOAD semantic, attributes that are not mentioned in the graph are LAZY or EAGER,
|
||||||
|
// depending on the mapping.
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1 + 2 for the eager C
|
||||||
|
assertEquals( 3L, statistics.getPrepareStatementCount() );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-14124")
|
||||||
|
public void testQueryByIdWithFetchGraphMultipleResults() {
|
||||||
|
Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics();
|
||||||
|
statistics.clear();
|
||||||
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
|
EntityGraph<CEntity> entityGraph = entityManager.createEntityGraph( CEntity.class );
|
||||||
|
entityGraph.addAttributeNodes( "a", "b" );
|
||||||
|
entityGraph.addSubgraph( "dList" ).addAttributeNodes( "e" );
|
||||||
|
|
||||||
|
TypedQuery<CEntity> query = entityManager.createQuery(
|
||||||
|
"select c from CEntity as c where c.id in :cid ",
|
||||||
|
CEntity.class
|
||||||
|
);
|
||||||
|
query.setHint( GraphSemantic.FETCH.getJpaHintName(), entityGraph );
|
||||||
|
query.setParameter( "cid", Arrays.asList( 1, 10001 ) );
|
||||||
|
|
||||||
|
List<CEntity> cEntityList = query.getResultList();
|
||||||
|
assertEquals( 2, cEntityList.size() );
|
||||||
|
|
||||||
|
for ( CEntity cEntity : cEntityList ) {
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getA() ) );
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getB() ) );
|
||||||
|
assertFalse( Hibernate.isInitialized( cEntity.getC() ) );
|
||||||
|
assertTrue( Hibernate.isInitialized( cEntity.getdList() ) );
|
||||||
|
cEntity.getdList().forEach( dEntity -> {
|
||||||
|
assertTrue( Hibernate.isInitialized( dEntity.getE() ) );
|
||||||
|
} );
|
||||||
|
|
||||||
|
// With FETCH semantic, attributes that are not mentioned in the graph are LAZY,
|
||||||
|
// even if they were EAGER in the mapping.
|
||||||
|
assertFalse( Hibernate.isInitialized( cEntity.getEagerC() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals( 1L, statistics.getPrepareStatementCount() );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
@Entity(name = "AEntity")
|
@Entity(name = "AEntity")
|
||||||
@Table(name = "A")
|
@Table(name = "A")
|
||||||
public static class AEntity {
|
public static class AEntity {
|
||||||
|
@ -366,6 +470,9 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private CEntity c;
|
private CEntity c;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
|
private CEntity eagerC;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
fetch = FetchType.LAZY,
|
fetch = FetchType.LAZY,
|
||||||
mappedBy = "c",
|
mappedBy = "c",
|
||||||
|
@ -419,6 +526,14 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
this.c = c;
|
this.c = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CEntity getEagerC() {
|
||||||
|
return eagerC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEagerC(CEntity eagerC) {
|
||||||
|
this.eagerC = eagerC;
|
||||||
|
}
|
||||||
|
|
||||||
public List<DEntity> getdList() {
|
public List<DEntity> getdList() {
|
||||||
return dList;
|
return dList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,18 @@ import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.PessimisticLockException;
|
import javax.persistence.PessimisticLockException;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.persistence.QueryTimeoutException;
|
import javax.persistence.QueryTimeoutException;
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.TransactionException;
|
import org.hibernate.TransactionException;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.Oracle10gDialect;
|
import org.hibernate.dialect.Oracle10gDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
|
||||||
import org.hibernate.jpa.AvailableSettings;
|
import org.hibernate.jpa.AvailableSettings;
|
||||||
import org.hibernate.jpa.QueryHints;
|
import org.hibernate.jpa.QueryHints;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
@ -43,9 +40,8 @@ import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.transaction.TransactionUtil;
|
import org.hibernate.testing.transaction.TransactionUtil;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -61,6 +57,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
private static final Logger log = Logger.getLogger( LockTest.class );
|
private static final Logger log = Logger.getLogger( LockTest.class );
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testFindWithTimeoutHint() {
|
public void testFindWithTimeoutHint() {
|
||||||
final Lock lock = new Lock();
|
final Lock lock = new Lock();
|
||||||
lock.setName( "name" );
|
lock.setName( "name" );
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.lock;
|
package org.hibernate.jpa.test.lock;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.jpa.QueryHints;
|
import org.hibernate.jpa.QueryHints;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.query.NativeQuery;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.hibernate.type.IntegerType;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -27,6 +26,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
@RequiresDialect(PostgreSQL82Dialect.class)
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41335")
|
||||||
@TestForIssue( jiraKey = "HHH-13493")
|
@TestForIssue( jiraKey = "HHH-13493")
|
||||||
public class NativeSQLQueryTimeoutTest extends BaseEntityManagerFunctionalTestCase {
|
public class NativeSQLQueryTimeoutTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,18 +19,18 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import javax.persistence.criteria.ParameterExpression;
|
import javax.persistence.criteria.ParameterExpression;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.internal.SessionImpl;
|
import org.hibernate.internal.SessionImpl;
|
||||||
import org.hibernate.jpa.AvailableSettings;
|
import org.hibernate.jpa.AvailableSettings;
|
||||||
import org.hibernate.jpa.QueryHints;
|
import org.hibernate.jpa.QueryHints;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.query.NativeQuery;
|
import org.hibernate.query.NativeQuery;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.transaction.TransactionUtil;
|
import org.hibernate.testing.transaction.TransactionUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -145,6 +145,7 @@ public class QueryLockingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testPessimisticForcedIncrementOverall() {
|
public void testPessimisticForcedIncrementOverall() {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -170,6 +171,7 @@ public class QueryLockingTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testPessimisticForcedIncrementSpecific() {
|
public void testPessimisticForcedIncrementSpecific() {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
|
@ -11,14 +11,14 @@ import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.LockModeType;
|
import javax.persistence.LockModeType;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
|
|
||||||
import org.hibernate.testing.transaction.TransactionUtil;
|
import org.hibernate.testing.transaction.TransactionUtil;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -67,6 +67,7 @@ public class StatementIsClosedAfterALockExceptionTest extends BaseEntityManagerF
|
||||||
|
|
||||||
@Test(timeout = 1000 * 30) //30 seconds
|
@Test(timeout = 1000 * 30) //30 seconds
|
||||||
@TestForIssue(jiraKey = "HHH-11617")
|
@TestForIssue(jiraKey = "HHH-11617")
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testStatementIsClosed() {
|
public void testStatementIsClosed() {
|
||||||
|
|
||||||
TransactionUtil.doInJPA( this::entityManagerFactory, em1 -> {
|
TransactionUtil.doInJPA( this::entityManagerFactory, em1 -> {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.query.NativeQuery;
|
import org.hibernate.query.NativeQuery;
|
||||||
|
@ -115,7 +116,8 @@ public class NativeQueryOrdinalParametersTest extends BaseEntityManagerFunctiona
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-12532")
|
@TestForIssue(jiraKey = "HHH-12532")
|
||||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
// Add RequiresDialect be Cockroach version 201
|
||||||
|
@RequiresDialect({ PostgreSQL82Dialect.class})
|
||||||
public void testCteNativeQueryOrdinalParameter() {
|
public void testCteNativeQueryOrdinalParameter() {
|
||||||
|
|
||||||
Node root1 = new Node();
|
Node root1 = new Node();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import javax.persistence.Tuple;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||||
import org.hibernate.dialect.PostgresPlusDialect;
|
import org.hibernate.dialect.PostgresPlusDialect;
|
||||||
|
@ -383,6 +384,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testNativeQueryNullPositionalParameter() throws Exception {
|
public void testNativeQueryNullPositionalParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
|
@ -418,6 +420,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@TestForIssue(jiraKey = "HHH-10161")
|
@TestForIssue(jiraKey = "HHH-10161")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testNativeQueryNullPositionalParameterParameter() throws Exception {
|
public void testNativeQueryNullPositionalParameterParameter() throws Exception {
|
||||||
|
@ -471,6 +474,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testNativeQueryNullNamedParameter() throws Exception {
|
public void testNativeQueryNullNamedParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
|
@ -506,6 +510,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@TestForIssue(jiraKey = "HHH-10161")
|
@TestForIssue(jiraKey = "HHH-10161")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testNativeQueryNullNamedParameterParameter() throws Exception {
|
public void testNativeQueryNullNamedParameterParameter() throws Exception {
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.hibernate.query.hhh14112;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Inheritance;
|
||||||
|
import javax.persistence.InheritanceType;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Where;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Ganesh Tiwari
|
||||||
|
* @author Nathan Xu
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-14112")
|
||||||
|
public class HHH14112Test extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCountSubObjectNotThrownExceptionBecauseOfWhere() {
|
||||||
|
doInJPA(this::sessionFactory, em -> {
|
||||||
|
em.createQuery( "SELECT count(*) FROM SubObject", Long.class).getSingleResult();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class<?>[] { HHH14112Test.Super.class, HHH14112Test.SubObject.class };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity(name = "Super")
|
||||||
|
@Inheritance(strategy = InheritanceType.JOINED)
|
||||||
|
@Where(clause = "DELETED = false")
|
||||||
|
public static class Super {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
public Long id;
|
||||||
|
|
||||||
|
public boolean deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity(name = "SubObject")
|
||||||
|
public static class SubObject extends Super {
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public int age;
|
||||||
|
|
||||||
|
public SubObject() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubObject(String name, int age) {
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.hibernate.query.hhh14116;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EnumType;
|
||||||
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Christian Beikov
|
||||||
|
* @author Nathan Xu
|
||||||
|
*/
|
||||||
|
@TestForIssue( jiraKey = "HHH-14116" )
|
||||||
|
public class HHH14116Test extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class<?>[] { HHH14116Test.User.class, HHH14116Test.Group.class };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoExceptionThrown() {
|
||||||
|
doInJPA( this::sessionFactory, em -> {
|
||||||
|
em.createQuery(
|
||||||
|
"SELECT g FROM User u JOIN u.groups g JOIN FETCH g.permissions JOIN FETCH g.tenant where u.id = ?1", Group.class )
|
||||||
|
.setParameter(1, 1L )
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity(name = "User")
|
||||||
|
@Table(name = "usr_tbl")
|
||||||
|
public static class User {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ManyToMany
|
||||||
|
private Set<Group> groups;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
@ElementCollection
|
||||||
|
private Set<Permission> permissions;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity(name = "Group")
|
||||||
|
@Table(name = "grp_tbl")
|
||||||
|
public static class Group {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
private User tenant;
|
||||||
|
|
||||||
|
@Enumerated(value = EnumType.STRING)
|
||||||
|
@ElementCollection
|
||||||
|
private Set<Permission> permissions;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Permission {
|
||||||
|
READ,
|
||||||
|
WRITE,
|
||||||
|
EXECUTE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.hibernate.test.annotations.fetchprofile;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.annotations.FetchProfile;
|
||||||
|
import org.hibernate.test.annotations.fetchprofile.mappedby.Address;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@FetchProfile(name = "customer-with-address", fetchOverrides = {
|
||||||
|
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address", mode = FetchMode.JOIN)
|
||||||
|
})
|
||||||
|
public class Customer6 {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
private Address address;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(Address address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package org.hibernate.test.annotations.fetchprofile;
|
||||||
|
|
||||||
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.test.annotations.fetchprofile.mappedby.Address;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
@TestForIssue( jiraKey = "HHH-14071" )
|
||||||
|
public class MappedByFetchProfileFunctionTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchWithOneToOneMappedBy() {
|
||||||
|
final Session session = openSession();
|
||||||
|
session.enableFetchProfile( "address-with-customer" );
|
||||||
|
final Transaction transaction = session.beginTransaction();
|
||||||
|
|
||||||
|
Address address = new Address();
|
||||||
|
address.setStreet("Test Road 1");
|
||||||
|
Customer6 customer = new Customer6();
|
||||||
|
customer.setName("Tester");
|
||||||
|
customer.setAddress(address);
|
||||||
|
|
||||||
|
session.persist(address);
|
||||||
|
session.persist(customer);
|
||||||
|
|
||||||
|
session.flush();
|
||||||
|
session.clear();
|
||||||
|
|
||||||
|
address = session.get(Address.class, address.getId());
|
||||||
|
assertTrue(Hibernate.isInitialized(address.getCustomer()));
|
||||||
|
session.delete(address.getCustomer());
|
||||||
|
session.delete(address);
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class<?>[] {
|
||||||
|
Customer6.class,
|
||||||
|
Address.class
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package org.hibernate.test.annotations.fetchprofile;
|
||||||
|
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.test.annotations.fetchprofile.mappedby.Address;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
@TestForIssue( jiraKey = "HHH-14071" )
|
||||||
|
public class MappedByFetchProfileUnitTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFetchProfileConfigured() {
|
||||||
|
Configuration config = new Configuration();
|
||||||
|
config.addAnnotatedClass( Customer6.class );
|
||||||
|
config.addAnnotatedClass( Address.class );
|
||||||
|
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
||||||
|
serviceRegistry
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"fetch profile not parsed properly",
|
||||||
|
sessionImpl.containsFetchProfileDefinition( "address-with-customer" )
|
||||||
|
);
|
||||||
|
assertTrue(
|
||||||
|
"fetch profile not parsed properly",
|
||||||
|
sessionImpl.containsFetchProfileDefinition( "customer-with-address" )
|
||||||
|
);
|
||||||
|
sessionImpl.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPackageConfiguredFetchProfile() {
|
||||||
|
Configuration config = new Configuration();
|
||||||
|
config.addAnnotatedClass( Customer6.class );
|
||||||
|
config.addAnnotatedClass( Address.class );
|
||||||
|
config.addPackage( Address.class.getPackage().getName() );
|
||||||
|
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
||||||
|
serviceRegistry
|
||||||
|
);
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"fetch profile not parsed properly",
|
||||||
|
sessionImpl.containsFetchProfileDefinition( "mappedBy-package-profile-1" )
|
||||||
|
);
|
||||||
|
assertTrue(
|
||||||
|
"fetch profile not parsed properly",
|
||||||
|
sessionImpl.containsFetchProfileDefinition( "mappedBy-package-profile-2" )
|
||||||
|
);
|
||||||
|
sessionImpl.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package org.hibernate.test.annotations.fetchprofile.mappedby;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.annotations.FetchProfile;
|
||||||
|
import org.hibernate.test.annotations.fetchprofile.Customer6;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@FetchProfile(name = "address-with-customer", fetchOverrides = {
|
||||||
|
@FetchProfile.FetchOverride(entity = Address.class, association = "customer", mode = FetchMode.JOIN)
|
||||||
|
})
|
||||||
|
public class Address {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private String street;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.LAZY, mappedBy = "address")
|
||||||
|
private Customer6 customer;
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreet(String street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Customer6 getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomer(Customer6 customer) {
|
||||||
|
this.customer = customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
@FetchProfile(name = "mappedBy-package-profile-1", fetchOverrides = {
|
||||||
|
@FetchProfile.FetchOverride(entity = Address.class, association = "customer", mode = FetchMode.JOIN)
|
||||||
|
})
|
||||||
|
@FetchProfile(name = "mappedBy-package-profile-2", fetchOverrides = {
|
||||||
|
@FetchProfile.FetchOverride(entity = Customer6.class, association = "address", mode = FetchMode.JOIN)
|
||||||
|
})
|
||||||
|
package org.hibernate.test.annotations.fetchprofile.mappedby;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.annotations.FetchProfile;
|
||||||
|
import org.hibernate.test.annotations.fetchprofile.Customer6;
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
@ -104,6 +105,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testQueryWithNullParameter(){
|
public void testQueryWithNullParameter(){
|
||||||
Chaos c0 = new Chaos();
|
Chaos c0 = new Chaos();
|
||||||
|
@ -189,6 +191,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
@SkipForDialect(value = Oracle8iDialect.class, jiraKey = "HHH-10161", comment = "Cannot convert untyped null (assumed to be BINARY type) to NUMBER")
|
||||||
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgreSQL9Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
public void testNativeQueryWithNullParameter(){
|
public void testNativeQueryWithNullParameter(){
|
||||||
Chaos c0 = new Chaos();
|
Chaos c0 = new Chaos();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQLDialect;
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.hibernate.dialect.TeradataDialect;
|
import org.hibernate.dialect.TeradataDialect;
|
||||||
|
@ -29,7 +30,7 @@ import static org.junit.Assert.assertNotNull;
|
||||||
*/
|
*/
|
||||||
public class Ejb3XmlTest extends BaseCoreFunctionalTestCase {
|
public class Ejb3XmlTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class},
|
@SkipForDialect(value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class, CockroachDialect.class},
|
||||||
comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
|
comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
|
||||||
@SkipForDialect(value = TeradataDialect.class,
|
@SkipForDialect(value = TeradataDialect.class,
|
||||||
jiraKey = "HHH-8190",
|
jiraKey = "HHH-8190",
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.persistence.OptimisticLockException;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -91,8 +92,21 @@ public class BatchOptimisticLockingTest extends
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
catch (Exception expected) {
|
catch (Exception expected) {
|
||||||
assertEquals( OptimisticLockException.class, expected.getClass());
|
assertEquals( OptimisticLockException.class, expected.getClass() );
|
||||||
assertEquals( "Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update Person set name=?, version=? where id=? and version=?", expected.getMessage() );
|
if ( getDialect() instanceof CockroachDialect ) {
|
||||||
|
// CockroachDB always runs in SERIALIZABLE isolation, and uses SQL state 40001 to indicate
|
||||||
|
// serialization failure.
|
||||||
|
assertEquals(
|
||||||
|
"org.hibernate.exception.LockAcquisitionException: could not execute batch",
|
||||||
|
expected.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertEquals(
|
||||||
|
"Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update Person set name=?, version=? where id=? and version=?",
|
||||||
|
expected.getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,13 @@ import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
|
import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -59,7 +62,8 @@ public class AndLobTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
final Type type = metadata.getEntityBinding( EntityImpl.class.getName() ).getProperty( "status" ).getType();
|
final Type type = metadata.getEntityBinding( EntityImpl.class.getName() ).getProperty( "status" ).getType();
|
||||||
final AttributeConverterTypeAdapter concreteType = assertTyping( AttributeConverterTypeAdapter.class, type );
|
final AttributeConverterTypeAdapter concreteType = assertTyping( AttributeConverterTypeAdapter.class, type );
|
||||||
assertEquals( Types.BLOB, concreteType.getSqlTypeDescriptor().getSqlType() );
|
SqlTypeDescriptor sqlTypeDescriptor = concreteType.getSqlTypeDescriptor();
|
||||||
|
assertEquals( Dialect.getDialect().remapSqlTypeDescriptor(BlobTypeDescriptor.BLOB_BINDING).getSqlType(), sqlTypeDescriptor.getSqlType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Converter
|
@Converter
|
||||||
|
|
|
@ -12,18 +12,16 @@ import javax.persistence.Convert;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.internal.MetadataImpl;
|
import org.hibernate.boot.internal.MetadataImpl;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -47,8 +45,9 @@ public class AndNationalizedTests extends BaseUnitTestCase {
|
||||||
|
|
||||||
final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() );
|
final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect
|
||||||
|| metadata.getDatabase().getDialect() instanceof DB2Dialect){
|
|| metadata.getDatabase().getDialect() instanceof DB2Dialect
|
||||||
// See issue HHH-10693 for PostgreSQL, HHH-12753 for DB2
|
|| metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
|
// See issue HHH-10693 for PostgreSQL and CockroachDB, HHH-12753 for DB2
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Types.VARCHAR,
|
Types.VARCHAR,
|
||||||
entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0]
|
entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0]
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.HANACloudColumnStoreDialect;
|
import org.hibernate.dialect.HANACloudColumnStoreDialect;
|
||||||
import org.hibernate.internal.util.ConfigHelper;
|
import org.hibernate.internal.util.ConfigHelper;
|
||||||
import org.hibernate.mapping.BasicValue;
|
import org.hibernate.mapping.BasicValue;
|
||||||
|
@ -46,6 +47,9 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
|
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
|
||||||
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||||
|
@ -110,7 +114,8 @@ public class AttributeConverterTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
|
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
|
||||||
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
||||||
assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() );
|
SqlTypeDescriptor sqlTypeDescriptor = basicType.getSqlTypeDescriptor();
|
||||||
|
assertEquals( Dialect.getDialect().remapSqlTypeDescriptor( ClobTypeDescriptor.CLOB_BINDING).getSqlType(), sqlTypeDescriptor.getSqlType() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -161,7 +166,8 @@ public class AttributeConverterTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
|
AbstractStandardBasicType basicType = assertTyping( AbstractStandardBasicType.class, type );
|
||||||
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
||||||
assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() );
|
SqlTypeDescriptor sqlTypeDescriptor = basicType.getSqlTypeDescriptor();
|
||||||
|
assertEquals( Dialect.getDialect().remapSqlTypeDescriptor(ClobTypeDescriptor.CLOB_BINDING).getSqlType(), sqlTypeDescriptor.getSqlType() );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
StandardServiceRegistryBuilder.destroy( ssr );
|
StandardServiceRegistryBuilder.destroy( ssr );
|
||||||
|
@ -190,7 +196,8 @@ public class AttributeConverterTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
AttributeConverterTypeAdapter basicType = assertTyping( AttributeConverterTypeAdapter.class, type );
|
AttributeConverterTypeAdapter basicType = assertTyping( AttributeConverterTypeAdapter.class, type );
|
||||||
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
assertSame( StringTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() );
|
||||||
assertEquals( Types.CLOB, basicType.getSqlTypeDescriptor().getSqlType() );
|
SqlTypeDescriptor sqlTypeDescriptor = basicType.getSqlTypeDescriptor();
|
||||||
|
assertEquals( Dialect.getDialect().remapSqlTypeDescriptor(ClobTypeDescriptor.CLOB_BINDING).getSqlType(), sqlTypeDescriptor.getSqlType() );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
StandardServiceRegistryBuilder.destroy( ssr );
|
StandardServiceRegistryBuilder.destroy( ssr );
|
||||||
|
|
|
@ -6,30 +6,19 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.hql;
|
package org.hibernate.test.hql;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
|
||||||
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.assertSame;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.sql.Date;
|
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
|
@ -41,6 +30,7 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
import org.hibernate.dialect.CUBRIDDialect;
|
import org.hibernate.dialect.CUBRIDDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
|
@ -715,7 +705,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
session = openSession();
|
session = openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
List results = session.createQuery( "from Human h where h.nickName in (:nickNames)" )
|
List results = session.createQuery( "from Human h where h.nickName in (:nickNames)" )
|
||||||
.setParameter("nickNames", Collections.emptySet() )
|
.setParameter( "nickNames", Collections.emptySet() )
|
||||||
.list();
|
.list();
|
||||||
assertEquals( 0, results.size() );
|
assertEquals( 0, results.size() );
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
@ -1017,6 +1007,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943")
|
||||||
public void testExpressionWithParamInFunction() {
|
public void testExpressionWithParamInFunction() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
@ -1047,7 +1038,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
else {
|
else {
|
||||||
s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setParameter( "bar", "xyz" ).list();
|
s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setParameter( "bar", "xyz" ).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getDialect() instanceof AbstractHANADialect ) {
|
if ( getDialect() instanceof AbstractHANADialect ) {
|
||||||
s.createQuery( "from Animal where abs(cast(1 as double) - cast(:param as double)) = 1.0" ).setParameter( "param", 1 ).list();
|
s.createQuery( "from Animal where abs(cast(1 as double) - cast(:param as double)) = 1.0" ).setParameter( "param", 1 ).list();
|
||||||
}
|
}
|
||||||
|
@ -1468,6 +1459,8 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
// (2) description is defined as a property of the superclass (Animal)
|
// (2) description is defined as a property of the superclass (Animal)
|
||||||
// (3) name is defined as a property of a particular subclass (Human)
|
// (3) name is defined as a property of a particular subclass (Human)
|
||||||
|
|
||||||
|
new SyntaxChecker( "from Zoo z join z.mammals as m where m.name.first = 'John'" ).checkAll();
|
||||||
|
|
||||||
new SyntaxChecker( "from Zoo z join z.mammals as m where m.pregnant = false" ).checkAll();
|
new SyntaxChecker( "from Zoo z join z.mammals as m where m.pregnant = false" ).checkAll();
|
||||||
new SyntaxChecker( "select m.pregnant from Zoo z join z.mammals as m where m.pregnant = false" ).checkAll();
|
new SyntaxChecker( "select m.pregnant from Zoo z join z.mammals as m where m.pregnant = false" ).checkAll();
|
||||||
|
|
||||||
|
@ -2891,6 +2884,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943")
|
||||||
@SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"})
|
@SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"})
|
||||||
public void testSelectExpressions() {
|
public void testSelectExpressions() {
|
||||||
createTestBaseData();
|
createTestBaseData();
|
||||||
|
@ -3224,7 +3218,8 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStandardFunctions() throws Exception {
|
@SkipForDialect(value = CockroachDialect.class, strictMatching = true)
|
||||||
|
public void testStandardFunctions() {
|
||||||
Session session = openSession();
|
Session session = openSession();
|
||||||
Transaction t = session.beginTransaction();
|
Transaction t = session.beginTransaction();
|
||||||
Product p = new Product();
|
Product p = new Product();
|
||||||
|
@ -3729,7 +3724,8 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
* <link>http://www.postgresql.org/docs/current/static/release-8-3.html</link>
|
* <link>http://www.postgresql.org/docs/current/static/release-8-3.html</link>
|
||||||
*/
|
*/
|
||||||
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect
|
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect
|
||||||
|| getDialect() instanceof HSQLDialect ) {
|
|| getDialect() instanceof HSQLDialect
|
||||||
|
|| getDialect() instanceof CockroachDialect ) {
|
||||||
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
|
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3738,7 +3734,8 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
session.createQuery(hql).list();
|
session.createQuery(hql).list();
|
||||||
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect
|
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect
|
||||||
|| getDialect() instanceof HSQLDialect ) {
|
|| getDialect() instanceof HSQLDialect
|
||||||
|
|| getDialect() instanceof CockroachDialect ) {
|
||||||
hql = "select bit_length(str(a.bodyWeight)) from Animal a";
|
hql = "select bit_length(str(a.bodyWeight)) from Animal a";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -32,15 +32,19 @@ public class NonUniqueIdTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
// Drop and recreate table so it has no primary key. The drop is done in a separate transaction because
|
||||||
|
// some databases do not support dropping and recreating in the same transaction.
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
session -> {
|
session -> {
|
||||||
// drop and recreate table so it has no primary key
|
|
||||||
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"DROP TABLE CATEGORY"
|
"DROP TABLE CATEGORY"
|
||||||
).executeUpdate();
|
).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
doInHibernate(
|
||||||
|
this::sessionFactory,
|
||||||
|
session -> {
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table CATEGORY( id integer not null, name varchar(255) )"
|
"create table CATEGORY( id integer not null, name varchar(255) )"
|
||||||
).executeUpdate();
|
).executeUpdate();
|
||||||
|
|
|
@ -17,9 +17,9 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -34,7 +34,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-11477")
|
@TestForIssue(jiraKey = "HHH-11477")
|
||||||
@RequiresDialect(PostgreSQL81Dialect.class)
|
@RequiresDialect({ PostgreSQL81Dialect.class, CockroachDialect.class })
|
||||||
public class LobStringTest extends BaseCoreFunctionalTestCase {
|
public class LobStringTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
private static final int LONG_STRING_SIZE = 3999;
|
private static final int LONG_STRING_SIZE = 3999;
|
||||||
|
@ -90,6 +90,7 @@ public class LobStringTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-11477")
|
@TestForIssue(jiraKey = "HHH-11477")
|
||||||
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
public void testUsingStringLobAnnotatedPropertyInNativeQuery() {
|
public void testUsingStringLobAnnotatedPropertyInNativeQuery() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
final List<TestEntity> results = session.createNativeQuery(
|
final List<TestEntity> results = session.createNativeQuery(
|
||||||
|
@ -116,6 +117,7 @@ public class LobStringTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-11477")
|
@TestForIssue(jiraKey = "HHH-11477")
|
||||||
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
public void testSelectStringLobAnnotatedInNativeQuery() {
|
public void testSelectStringLobAnnotatedInNativeQuery() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
final List<String> results = session.createNativeQuery(
|
final List<String> results = session.createNativeQuery(
|
||||||
|
@ -133,6 +135,7 @@ public class LobStringTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-11477")
|
@TestForIssue(jiraKey = "HHH-11477")
|
||||||
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
public void testUsingLobPropertyInNativeQuery() {
|
public void testUsingLobPropertyInNativeQuery() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
final List<String> results = session.createNativeQuery(
|
final List<String> results = session.createNativeQuery(
|
||||||
|
@ -150,6 +153,7 @@ public class LobStringTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-11477")
|
@TestForIssue(jiraKey = "HHH-11477")
|
||||||
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
public void testSelectClobPropertyInNativeQuery() {
|
public void testSelectClobPropertyInNativeQuery() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
final List<byte[]> results = session.createNativeQuery(
|
final List<byte[]> results = session.createNativeQuery(
|
||||||
|
|
|
@ -21,8 +21,7 @@ import javax.persistence.Table;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.*;
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -5,17 +5,14 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.dialect.MySQL57Dialect;
|
|
||||||
import org.hibernate.dialect.MySQL8Dialect;
|
import org.hibernate.dialect.MySQL8Dialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL95Dialect;
|
import org.hibernate.dialect.PostgreSQL95Dialect;
|
||||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
import org.hibernate.dialect.SybaseDialect;
|
import org.hibernate.dialect.SybaseDialect;
|
||||||
|
@ -212,6 +213,7 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-12257")
|
@TestForIssue(jiraKey = "HHH-12257")
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testRefreshWithExplicitHigherLevelLockMode() {
|
public void testRefreshWithExplicitHigherLevelLockMode() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
A a = session.get( A.class, id );
|
A a = session.get( A.class, id );
|
||||||
|
|
|
@ -8,10 +8,9 @@ import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL95Dialect;
|
import org.hibernate.dialect.PostgreSQL95Dialect;
|
||||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
|
||||||
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
import org.hibernate.testing.jdbc.SQLStatementInterceptor;
|
||||||
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
|
@ -81,7 +82,8 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
|
||||||
assertNotNull( pc );
|
assertNotNull( pc );
|
||||||
|
|
||||||
Property prop = pc.getProperty( "nvarcharAtt" );
|
Property prop = pc.getProperty( "nvarcharAtt" );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
// See issue HHH-10693
|
// See issue HHH-10693
|
||||||
assertSame( StringType.INSTANCE, prop.getType() );
|
assertSame( StringType.INSTANCE, prop.getType() );
|
||||||
}else{
|
}else{
|
||||||
|
@ -89,7 +91,8 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = pc.getProperty( "materializedNclobAtt" );
|
prop = pc.getProperty( "materializedNclobAtt" );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
// See issue HHH-10693
|
// See issue HHH-10693
|
||||||
assertSame( MaterializedClobType.INSTANCE, prop.getType() );
|
assertSame( MaterializedClobType.INSTANCE, prop.getType() );
|
||||||
}else {
|
}else {
|
||||||
|
@ -102,7 +105,8 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
|
||||||
assertSame( NTextType.INSTANCE, prop.getType() );
|
assertSame( NTextType.INSTANCE, prop.getType() );
|
||||||
|
|
||||||
prop = pc.getProperty( "ncharArrAtt" );
|
prop = pc.getProperty( "ncharArrAtt" );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
// See issue HHH-10693
|
// See issue HHH-10693
|
||||||
assertSame( CharacterArrayType.INSTANCE, prop.getType() );
|
assertSame( CharacterArrayType.INSTANCE, prop.getType() );
|
||||||
}else {
|
}else {
|
||||||
|
@ -110,7 +114,8 @@ public class SimpleNationalizedTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
prop = pc.getProperty( "ncharacterAtt" );
|
prop = pc.getProperty( "ncharacterAtt" );
|
||||||
if ( metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ) {
|
if ( metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ) {
|
||||||
// See issue HHH-10693
|
// See issue HHH-10693
|
||||||
assertSame( CharacterType.INSTANCE, prop.getType() );
|
assertSame( CharacterType.INSTANCE, prop.getType() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
|
@ -51,7 +52,8 @@ public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase {
|
||||||
final Metadata metadata = ms.buildMetadata();
|
final Metadata metadata = ms.buildMetadata();
|
||||||
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
|
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
|
||||||
final Property nameAttribute = pc.getProperty( "name" );
|
final Property nameAttribute = pc.getProperty( "name" );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
// See issue HHH-10693
|
// See issue HHH-10693
|
||||||
assertSame( StringType.INSTANCE, nameAttribute.getType() );
|
assertSame( StringType.INSTANCE, nameAttribute.getType() );
|
||||||
}else {
|
}else {
|
||||||
|
@ -78,7 +80,8 @@ public class UseNationalizedCharDataSettingTest extends BaseUnitTestCase {
|
||||||
final Metadata metadata = ms.buildMetadata();
|
final Metadata metadata = ms.buildMetadata();
|
||||||
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
|
final PersistentClass pc = metadata.getEntityBinding( NationalizedBySettingEntity.class.getName() );
|
||||||
final Property nameAttribute = pc.getProperty( "flag" );
|
final Property nameAttribute = pc.getProperty( "flag" );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ){
|
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect ||
|
||||||
|
metadata.getDatabase().getDialect() instanceof CockroachDialect ){
|
||||||
assertSame( CharacterType.INSTANCE, nameAttribute.getType() );
|
assertSame( CharacterType.INSTANCE, nameAttribute.getType() );
|
||||||
}else {
|
}else {
|
||||||
assertSame( CharacterNCharType.INSTANCE, nameAttribute.getType() );
|
assertSame( CharacterNCharType.INSTANCE, nameAttribute.getType() );
|
||||||
|
|
|
@ -8,19 +8,17 @@ package org.hibernate.test.optlock;
|
||||||
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
|
||||||
import org.hibernate.JDBCException;
|
import org.hibernate.JDBCException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.StaleStateException;
|
import org.hibernate.StaleStateException;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,20 +159,23 @@ public class OptimisticLockTest extends BaseCoreFunctionalTestCase {
|
||||||
private void checkException(Session mainSession, PersistenceException e) {
|
private void checkException(Session mainSession, PersistenceException e) {
|
||||||
final Throwable cause = e.getCause();
|
final Throwable cause = e.getCause();
|
||||||
if ( cause instanceof JDBCException ) {
|
if ( cause instanceof JDBCException ) {
|
||||||
// SQLServer will report this condition via a SQLException
|
if ( getDialect() instanceof SQLServerDialect && ((JDBCException) cause).getErrorCode() == 3960 ) {
|
||||||
// when using its SNAPSHOT transaction isolation...
|
// SQLServer will report this condition via a SQLException
|
||||||
|
// when using its SNAPSHOT transaction isolation.
|
||||||
if ( !(getDialect() instanceof SQLServerDialect && ((JDBCException) cause).getErrorCode() == 3960) ) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// it seems to "lose track" of the transaction as well...
|
// it seems to "lose track" of the transaction as well...
|
||||||
mainSession.getTransaction().rollback();
|
mainSession.getTransaction().rollback();
|
||||||
mainSession.beginTransaction();
|
mainSession.beginTransaction();
|
||||||
}
|
}
|
||||||
|
else if ( getDialect() instanceof CockroachDialect && ((JDBCException) cause).getSQLState().equals( "40001")) {
|
||||||
|
// CockroachDB always runs in SERIALIZABLE isolation, and uses SQL state 40001 to indicate
|
||||||
|
// serialization failure.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( !(cause instanceof StaleObjectStateException) && !(cause instanceof StaleStateException) ) {
|
else if ( !(cause instanceof StaleObjectStateException) && !(cause instanceof StaleStateException) ) {
|
||||||
fail( "expectd StaleObjectStateException or StaleStateException exception but is" + cause );
|
fail( "expected StaleObjectStateException or StaleStateException exception but is " + cause );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,19 +16,15 @@ import java.sql.Types;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import javax.persistence.ParameterMode;
|
import javax.persistence.ParameterMode;
|
||||||
import javax.persistence.StoredProcedureQuery;
|
import javax.persistence.StoredProcedureQuery;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.procedure.ProcedureCall;
|
import org.hibernate.procedure.ProcedureCall;
|
||||||
import org.hibernate.type.StringType;
|
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.type.StringType;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.dialect.SQLServer2012Dialect;
|
import org.hibernate.dialect.SQLServer2012Dialect;
|
||||||
|
import org.hibernate.testing.DialectChecks;
|
||||||
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ import static org.junit.Assert.fail;
|
||||||
PostgreSQL82Dialect.class,
|
PostgreSQL82Dialect.class,
|
||||||
SQLServer2012Dialect.class,
|
SQLServer2012Dialect.class,
|
||||||
})
|
})
|
||||||
|
@RequiresDialectFeature(DialectChecks.SupportSchemaCreation.class)
|
||||||
public class AlterTableQuoteDefaultSchemaTest extends AbstractAlterTableQuoteSchemaTest {
|
public class AlterTableQuoteDefaultSchemaTest extends AbstractAlterTableQuoteSchemaTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.dialect.SQLServer2012Dialect;
|
import org.hibernate.dialect.SQLServer2012Dialect;
|
||||||
|
import org.hibernate.testing.DialectChecks;
|
||||||
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
|
@ -45,6 +47,7 @@ import static org.junit.Assert.fail;
|
||||||
PostgreSQL82Dialect.class,
|
PostgreSQL82Dialect.class,
|
||||||
SQLServer2012Dialect.class,
|
SQLServer2012Dialect.class,
|
||||||
})
|
})
|
||||||
|
@RequiresDialectFeature(DialectChecks.SupportSchemaCreation.class)
|
||||||
public class AlterTableQuoteSpecifiedSchemaTest extends AbstractAlterTableQuoteSchemaTest {
|
public class AlterTableQuoteSpecifiedSchemaTest extends AbstractAlterTableQuoteSchemaTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
|
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
|
||||||
|
import org.hibernate.testing.DialectChecks;
|
||||||
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(PostgreSQL81Dialect.class)
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
|
@RequiresDialectFeature(DialectChecks.SupportSchemaCreation.class)
|
||||||
public class PostgreSQLMultipleSchemaSequenceTest extends BaseUnitTestCase {
|
public class PostgreSQLMultipleSchemaSequenceTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
private File output;
|
private File output;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Index;
|
import javax.persistence.Index;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
@ -22,6 +23,7 @@ import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
@ -38,6 +40,7 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-1872")
|
@TestForIssue(jiraKey = "HHH-1872")
|
||||||
@RequiresDialect(PostgreSQL81Dialect.class)
|
@RequiresDialect(PostgreSQL81Dialect.class)
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/24897")
|
||||||
public class SchemaUpdateWithViewsTest extends BaseNonConfigCoreFunctionalTestCase {
|
public class SchemaUpdateWithViewsTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
protected ServiceRegistry serviceRegistry;
|
protected ServiceRegistry serviceRegistry;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
@ -87,7 +88,7 @@ public class SchemaCreationTest {
|
||||||
isUniqueConstraintCreated = true;
|
isUniqueConstraintCreated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( dialect instanceof PostgreSQL81Dialect) {
|
else if ( dialect instanceof PostgreSQL81Dialect || dialect instanceof CockroachDialect ) {
|
||||||
if (statement.toLowerCase().startsWith("alter table if exists category add constraint")
|
if (statement.toLowerCase().startsWith("alter table if exists category add constraint")
|
||||||
&& statement.toLowerCase().contains("unique (code)")) {
|
&& statement.toLowerCase().contains("unique (code)")) {
|
||||||
isUniqueConstraintCreated = true;
|
isUniqueConstraintCreated = true;
|
||||||
|
|
|
@ -16,8 +16,10 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||||
import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
|
import org.hibernate.tool.schema.JdbcMetadaAccessStrategy;
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ import org.junit.Test;
|
||||||
@RequiresDialect(PostgreSQL81Dialect.class),
|
@RequiresDialect(PostgreSQL81Dialect.class),
|
||||||
@RequiresDialect(H2Dialect.class)
|
@RequiresDialect(H2Dialect.class)
|
||||||
})
|
})
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/10028")
|
||||||
public class ViewValidationTest extends BaseCoreFunctionalTestCase {
|
public class ViewValidationTest extends BaseCoreFunctionalTestCase {
|
||||||
private StandardServiceRegistry ssr;
|
private StandardServiceRegistry ssr;
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,11 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.hibernate.test.util.jdbc.TimeZoneConnectionProvider;
|
import org.hibernate.test.util.jdbc.TimeZoneConnectionProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -58,6 +60,7 @@ public class JdbcTimestampWithoutUTCTimeZoneTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/3781")
|
||||||
public void testTimeZone() {
|
public void testTimeZone() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
Person person = new Person();
|
Person person = new Person();
|
||||||
|
|
|
@ -13,18 +13,10 @@ import static org.junit.Assert.assertSame;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.*;
|
||||||
import org.hibernate.dialect.Dialect;
|
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
|
||||||
import org.hibernate.dialect.PostgreSQLDialect;
|
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
|
||||||
import org.hibernate.dialect.SybaseDialect;
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.*;
|
||||||
import org.hibernate.type.descriptor.sql.IntegerTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +39,13 @@ public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
|
||||||
assertSame( IntegerTypeDescriptor.INSTANCE, remapSqlTypeDescriptor( IntegerTypeDescriptor.INSTANCE ) );
|
assertSame( IntegerTypeDescriptor.INSTANCE, remapSqlTypeDescriptor( IntegerTypeDescriptor.INSTANCE ) );
|
||||||
|
|
||||||
// A few dialects explicitly override BlobTypeDescriptor.DEFAULT
|
// A few dialects explicitly override BlobTypeDescriptor.DEFAULT
|
||||||
if ( PostgreSQL81Dialect.class.isInstance( getDialect() ) || PostgreSQLDialect.class.isInstance( getDialect() ) ) {
|
if ( CockroachDialect.class.isInstance( getDialect() )) {
|
||||||
|
assertSame(
|
||||||
|
VarbinaryTypeDescriptor.INSTANCE,
|
||||||
|
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if ( PostgreSQL81Dialect.class.isInstance( getDialect() ) || PostgreSQLDialect.class.isInstance( getDialect() ) ) {
|
||||||
assertSame(
|
assertSame(
|
||||||
BlobTypeDescriptor.BLOB_BINDING,
|
BlobTypeDescriptor.BLOB_BINDING,
|
||||||
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )
|
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )
|
||||||
|
|
|
@ -53,10 +53,15 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery( "drop table MATERIAL_RATINGS" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table BUILDING_RATINGS" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "BUILDING_RATINGS" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table MAIN_TABLE" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
doInHibernate(
|
||||||
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table MAIN_TABLE( " +
|
"create table MAIN_TABLE( " +
|
||||||
|
|
|
@ -50,7 +50,12 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery( "DROP TABLE MAIN_TABLE" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
doInHibernate(
|
||||||
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table MAIN_TABLE( " +
|
"create table MAIN_TABLE( " +
|
||||||
|
|
|
@ -8,9 +8,7 @@ package org.hibernate.test.where.hbm;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -37,10 +35,15 @@ public class LazyManyToManyNonUniqueIdNotFoundWhereTest extends BaseCoreFunction
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery( "drop table MATERIAL_RATINGS" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table BUILDING_RATINGS" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "BUILDING_RATINGS" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" )).executeUpdate();
|
||||||
session.createNativeQuery( "drop table MAIN_TABLE" ).executeUpdate();
|
session.createNativeQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
doInHibernate(
|
||||||
|
this::sessionFactory, session -> {
|
||||||
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table MAIN_TABLE( " +
|
"create table MAIN_TABLE( " +
|
||||||
|
@ -156,7 +159,7 @@ public class LazyManyToManyNonUniqueIdNotFoundWhereTest extends BaseCoreFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-12875")
|
@TestForIssue( jiraKey = "HHH-12875" )
|
||||||
public void testInitializeFromUniqueAssociationTable() {
|
public void testInitializeFromUniqueAssociationTable() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
@ -185,7 +188,7 @@ public class LazyManyToManyNonUniqueIdNotFoundWhereTest extends BaseCoreFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-12875")
|
@TestForIssue( jiraKey = "HHH-12875" )
|
||||||
public void testInitializeFromNonUniqueAssociationTable() {
|
public void testInitializeFromNonUniqueAssociationTable() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
|
|
@ -41,11 +41,15 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
|
||||||
public void setup() {
|
public void setup() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
session.createNativeQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" ) ).executeUpdate();
|
||||||
|
session.createNativeQuery( getDialect().getDropTableString( "BUILDING_RATINGS" ) ).executeUpdate();
|
||||||
|
session.createNativeQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" ) ).executeUpdate();
|
||||||
|
session.createNativeQuery( getDialect().getDropTableString( "MAIN_TABLE" ) ).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
session.createNativeQuery( "drop table MATERIAL_RATINGS" ).executeUpdate();
|
doInHibernate(
|
||||||
session.createNativeQuery( "drop table BUILDING_RATINGS" ).executeUpdate();
|
this::sessionFactory, session -> {
|
||||||
session.createNativeQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate();
|
|
||||||
session.createNativeQuery( "drop table MAIN_TABLE" ).executeUpdate();
|
|
||||||
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table MAIN_TABLE( " +
|
"create table MAIN_TABLE( " +
|
||||||
|
|
|
@ -41,9 +41,12 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
|
||||||
public void setup() {
|
public void setup() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory, session -> {
|
this::sessionFactory, session -> {
|
||||||
|
session.createNativeQuery( getDialect().getDropTableString( "MAIN_TABLE" ) ).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
session.createNativeQuery( "DROP TABLE MAIN_TABLE" ).executeUpdate();
|
doInHibernate(
|
||||||
|
this::sessionFactory, session -> {
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"create table MAIN_TABLE( " +
|
"create table MAIN_TABLE( " +
|
||||||
"ID integer not null, NAME varchar(255) not null, CODE varchar(10) not null, " +
|
"ID integer not null, NAME varchar(255) not null, CODE varchar(10) not null, " +
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package org.hibernate.test.bulkid;
|
package org.hibernate.test.bulkid;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||||
import org.hibernate.hql.spi.id.inline.InlineIdsInClauseBulkIdStrategy;
|
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
@RequiresDialect(PostgreSQL82Dialect.class)
|
||||||
|
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/5807")
|
||||||
public class GlobalTemporaryTableBulkCompositeIdTest extends AbstractBulkCompositeIdTest {
|
public class GlobalTemporaryTableBulkCompositeIdTest extends AbstractBulkCompositeIdTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
import org.hibernate.dialect.SybaseAnywhereDialect;
|
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||||
import org.hibernate.dialect.SybaseDialect;
|
import org.hibernate.dialect.SybaseDialect;
|
||||||
import org.hibernate.dialect.TeradataDialect;
|
import org.hibernate.dialect.TeradataDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.function.SQLFunction;
|
import org.hibernate.dialect.function.SQLFunction;
|
||||||
import org.hibernate.engine.query.spi.HQLQueryPlan;
|
import org.hibernate.engine.query.spi.HQLQueryPlan;
|
||||||
import org.hibernate.engine.query.spi.ReturnMetadata;
|
import org.hibernate.engine.query.spi.ReturnMetadata;
|
||||||
|
@ -169,7 +170,8 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
Oracle8iDialect.class,
|
Oracle8iDialect.class,
|
||||||
AbstractHANADialect.class,
|
AbstractHANADialect.class,
|
||||||
PostgreSQL81Dialect.class,
|
PostgreSQL81Dialect.class,
|
||||||
MySQLDialect.class
|
MySQLDialect.class,
|
||||||
|
CockroachDialect.class
|
||||||
} )
|
} )
|
||||||
|
|
||||||
public void testRowValueConstructorSyntaxInInListBeingTranslated() {
|
public void testRowValueConstructorSyntaxInInListBeingTranslated() {
|
||||||
|
@ -406,6 +408,10 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
// parser does not; so the outputs do not match here...
|
// parser does not; so the outputs do not match here...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( getDialect() instanceof CockroachDialect ) {
|
||||||
|
// CockroachDB turns "float" into "float4" so the outputs won't match.
|
||||||
|
return;
|
||||||
|
}
|
||||||
assertTranslation( "from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0" );
|
assertTranslation( "from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +799,8 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
|| getDialect() instanceof SybaseASE15Dialect
|
|| getDialect() instanceof SybaseASE15Dialect
|
||||||
|| getDialect() instanceof SybaseAnywhereDialect
|
|| getDialect() instanceof SybaseAnywhereDialect
|
||||||
|| getDialect() instanceof SQLServerDialect
|
|| getDialect() instanceof SQLServerDialect
|
||||||
|| getDialect() instanceof IngresDialect) {
|
|| getDialect() instanceof IngresDialect
|
||||||
|
) {
|
||||||
// SybaseASE15Dialect and SybaseAnywhereDialect support '||'
|
// SybaseASE15Dialect and SybaseAnywhereDialect support '||'
|
||||||
// MySQL uses concat(x, y, z)
|
// MySQL uses concat(x, y, z)
|
||||||
// SQL Server replaces '||' with '+'
|
// SQL Server replaces '||' with '+'
|
||||||
|
@ -890,6 +897,7 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
|
|
||||||
if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
|
if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
|
||||||
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) return;
|
if ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) return;
|
||||||
|
if ( getDialect() instanceof CockroachDB192Dialect ) return;
|
||||||
if ( getDialect() instanceof TeradataDialect) return;
|
if ( getDialect() instanceof TeradataDialect) return;
|
||||||
if ( ! H2Dialect.class.isInstance( getDialect() ) ) {
|
if ( ! H2Dialect.class.isInstance( getDialect() ) ) {
|
||||||
// H2 has no year function
|
// H2 has no year function
|
||||||
|
@ -1070,6 +1078,7 @@ public class HQLTest extends QueryTranslatorTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(CockroachDialect.class)
|
||||||
public void testSelectStandardFunctionsNoParens() throws Exception {
|
public void testSelectStandardFunctionsNoParens() throws Exception {
|
||||||
assertTranslation( "select current_date, current_time, current_timestamp from Animal" );
|
assertTranslation( "select current_date, current_time, current_timestamp from Animal" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQLDialect;
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class CustomSQLTest extends LegacyTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@RequiresDialectFeature( NonIdentityGeneratorChecker.class )
|
@RequiresDialectFeature( NonIdentityGeneratorChecker.class )
|
||||||
@SkipForDialect( value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class}, jiraKey = "HHH-6704")
|
@SkipForDialect( value = {PostgreSQL81Dialect.class, PostgreSQLDialect.class, CockroachDialect.class}, jiraKey = "HHH-6704")
|
||||||
public void testInsert() throws HibernateException, SQLException {
|
public void testInsert() throws HibernateException, SQLException {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
|
|
@ -52,6 +52,7 @@ import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.InterbaseDialect;
|
import org.hibernate.dialect.InterbaseDialect;
|
||||||
import org.hibernate.dialect.MckoiDialect;
|
import org.hibernate.dialect.MckoiDialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Oracle12cDialect;
|
import org.hibernate.dialect.Oracle12cDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PointbaseDialect;
|
import org.hibernate.dialect.PointbaseDialect;
|
||||||
|
@ -388,6 +389,7 @@ public class FooBarTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/43007")
|
||||||
public void testQuery() throws Exception {
|
public void testQuery() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction txn = s.beginTransaction();
|
Transaction txn = s.beginTransaction();
|
||||||
|
@ -2290,6 +2292,8 @@ public class FooBarTest extends LegacyTestCase {
|
||||||
!( SybaseDialect.class.isAssignableFrom( getDialect().getClass() ) ) &&
|
!( SybaseDialect.class.isAssignableFrom( getDialect().getClass() ) ) &&
|
||||||
!( SQLServerDialect.class.isAssignableFrom( getDialect().getClass() ) ) &&
|
!( SQLServerDialect.class.isAssignableFrom( getDialect().getClass() ) ) &&
|
||||||
!( getDialect() instanceof PostgreSQLDialect ) && !(getDialect() instanceof PostgreSQL81Dialect ) &&
|
!( getDialect() instanceof PostgreSQLDialect ) && !(getDialect() instanceof PostgreSQL81Dialect ) &&
|
||||||
|
!(getDialect() instanceof CockroachDialect ) &&
|
||||||
|
|
||||||
!( getDialect() instanceof AbstractHANADialect) ) {
|
!( getDialect() instanceof AbstractHANADialect) ) {
|
||||||
// SybaseAnywhereDialect supports implicit conversions from strings to ints
|
// SybaseAnywhereDialect supports implicit conversions from strings to ints
|
||||||
s.createQuery(
|
s.createQuery(
|
||||||
|
@ -2365,7 +2369,8 @@ public class FooBarTest extends LegacyTestCase {
|
||||||
|
|
||||||
s.delete(bar);
|
s.delete(bar);
|
||||||
|
|
||||||
if ( getDialect() instanceof DB2Dialect || getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect ) {
|
if ( getDialect() instanceof DB2Dialect || getDialect() instanceof PostgreSQLDialect || getDialect() instanceof PostgreSQL81Dialect || getDialect() instanceof CockroachDialect
|
||||||
|
) {
|
||||||
s.createQuery( "select one from One one join one.manies many group by one order by count(many)" ).iterate();
|
s.createQuery( "select one from One one join one.manies many group by one order by count(many)" ).iterate();
|
||||||
s.createQuery( "select one from One one join one.manies many group by one having count(many) < 5" )
|
s.createQuery( "select one from One one join one.manies many group by one having count(many) < 5" )
|
||||||
.iterate();
|
.iterate();
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQLDialect;
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory;
|
import org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
@ -39,7 +40,8 @@ public abstract class LegacyTestCase extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
protected boolean supportsLockingNullableSideOfJoin(Dialect dialect) {
|
protected boolean supportsLockingNullableSideOfJoin(Dialect dialect) {
|
||||||
// db2 and pgsql do *NOT*
|
// db2 and pgsql do *NOT*
|
||||||
return ! ( DB2Dialect.class.isInstance( dialect ) || PostgreSQL81Dialect.class.isInstance( dialect ) || PostgreSQLDialect.class.isInstance( dialect ));
|
return ! ( DB2Dialect.class.isInstance( dialect ) || PostgreSQL81Dialect.class.isInstance( dialect ) || PostgreSQLDialect.class.isInstance( dialect ) ||
|
||||||
|
CockroachDialect.class.isInstance( dialect ));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String extractFromSystem(String systemPropertyName) {
|
protected static String extractFromSystem(String systemPropertyName) {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.MckoiDialect;
|
import org.hibernate.dialect.MckoiDialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.SAPDBDialect;
|
import org.hibernate.dialect.SAPDBDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.jdbc.AbstractWork;
|
import org.hibernate.jdbc.AbstractWork;
|
||||||
|
@ -196,6 +197,7 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871")
|
||||||
public void testSelfManyToOne() throws Exception {
|
public void testSelfManyToOne() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
@ -220,6 +222,7 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871")
|
||||||
public void testExample() throws Exception {
|
public void testExample() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
@ -248,6 +249,7 @@ public class MultiTableTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testMultiTable() throws Exception {
|
public void testMultiTable() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
@ -391,6 +393,7 @@ public class MultiTableTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testMultiTableGeneratedId() throws Exception {
|
public void testMultiTableGeneratedId() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
@ -514,6 +517,7 @@ public class MultiTableTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871")
|
||||||
public void testMultiTableCollections() throws Exception {
|
public void testMultiTableCollections() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
@ -586,6 +590,7 @@ public class MultiTableTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/27871")
|
||||||
public void testMultiTableManyToOne() throws Exception {
|
public void testMultiTableManyToOne() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction t = s.beginTransaction();
|
Transaction t = s.beginTransaction();
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.IngresDialect;
|
import org.hibernate.dialect.IngresDialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.TeradataDialect;
|
import org.hibernate.dialect.TeradataDialect;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.internal.SessionImpl;
|
import org.hibernate.internal.SessionImpl;
|
||||||
import org.hibernate.jdbc.AbstractWork;
|
import org.hibernate.jdbc.AbstractWork;
|
||||||
|
@ -1094,6 +1095,7 @@ public class ParentChildTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect( value = CockroachDialect.class )
|
||||||
public void testLocking() throws Exception {
|
public void testLocking() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
@ -1209,7 +1211,8 @@ public class ParentChildTest extends LegacyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoadAfterNonExists() throws HibernateException, SQLException {
|
@SkipForDialect(value = CockroachDialect.class, comment = "Uses READ_COMMITTED isolation")
|
||||||
|
public void testLoadAfterNonExists() throws HibernateException, SQLException {
|
||||||
Session session = openSession();
|
Session session = openSession();
|
||||||
if ( ( getDialect() instanceof MySQLDialect ) || ( getDialect() instanceof IngresDialect ) ) {
|
if ( ( getDialect() instanceof MySQLDialect ) || ( getDialect() instanceof IngresDialect ) ) {
|
||||||
session.doWork(
|
session.doWork(
|
||||||
|
|
|
@ -553,7 +553,7 @@ public final class CollectionMetadataGenerator {
|
||||||
final IdMappingData referencedIdMapping = mainGenerator.getEntitiesConfigurations()
|
final IdMappingData referencedIdMapping = mainGenerator.getEntitiesConfigurations()
|
||||||
.get( referencedEntityName ).getIdMappingData();
|
.get( referencedEntityName ).getIdMappingData();
|
||||||
final int currentIndex = queryGeneratorBuilder == null ? 0 : queryGeneratorBuilder.getCurrentIndex();
|
final int currentIndex = queryGeneratorBuilder == null ? 0 : queryGeneratorBuilder.getCurrentIndex();
|
||||||
if ( "".equals( mapKey ) ) {
|
if ( mapKey != null && mapKey.isEmpty() ) {
|
||||||
// The key of the map is the id of the entity.
|
// The key of the map is the id of the entity.
|
||||||
return new MiddleComponentData(
|
return new MiddleComponentData(
|
||||||
new MiddleMapKeyIdComponentMapper(
|
new MiddleMapKeyIdComponentMapper(
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.hibernate.envers.internal.EnversMessageLogger;
|
||||||
import org.hibernate.envers.internal.tools.MappingTools;
|
import org.hibernate.envers.internal.tools.MappingTools;
|
||||||
import org.hibernate.envers.internal.tools.ReflectionTools;
|
import org.hibernate.envers.internal.tools.ReflectionTools;
|
||||||
import org.hibernate.envers.internal.tools.StringTools;
|
import org.hibernate.envers.internal.tools.StringTools;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.mapping.Component;
|
import org.hibernate.mapping.Component;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
|
@ -617,7 +618,7 @@ public class AuditedPropertiesReader {
|
||||||
|
|
||||||
private void setPropertyRelationMappedBy(XProperty property, PropertyAuditingData propertyData) {
|
private void setPropertyRelationMappedBy(XProperty property, PropertyAuditingData propertyData) {
|
||||||
final OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
final OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
||||||
if ( oneToMany != null && !"".equals( oneToMany.mappedBy() ) ) {
|
if ( oneToMany != null && StringHelper.isNotEmpty( oneToMany.mappedBy() ) ) {
|
||||||
propertyData.setRelationMappedBy( oneToMany.mappedBy() );
|
propertyData.setRelationMappedBy( oneToMany.mappedBy() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,7 +627,7 @@ public class AuditedPropertiesReader {
|
||||||
final AuditMappedBy auditMappedBy = property.getAnnotation( AuditMappedBy.class );
|
final AuditMappedBy auditMappedBy = property.getAnnotation( AuditMappedBy.class );
|
||||||
if ( auditMappedBy != null ) {
|
if ( auditMappedBy != null ) {
|
||||||
propertyData.setAuditMappedBy( auditMappedBy.mappedBy() );
|
propertyData.setAuditMappedBy( auditMappedBy.mappedBy() );
|
||||||
if ( !"".equals( auditMappedBy.positionMappedBy() ) ) {
|
if ( StringHelper.isNotEmpty( auditMappedBy.positionMappedBy() ) ) {
|
||||||
propertyData.setPositionMappedBy( auditMappedBy.positionMappedBy() );
|
propertyData.setPositionMappedBy( auditMappedBy.positionMappedBy() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.envers.Audited;
|
||||||
import org.hibernate.envers.ModificationStore;
|
import org.hibernate.envers.ModificationStore;
|
||||||
import org.hibernate.envers.configuration.internal.GlobalConfiguration;
|
import org.hibernate.envers.configuration.internal.GlobalConfiguration;
|
||||||
import org.hibernate.envers.configuration.internal.metadata.MetadataTools;
|
import org.hibernate.envers.configuration.internal.metadata.MetadataTools;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the audited properties for components.
|
* Reads the audited properties for components.
|
||||||
|
@ -45,7 +46,7 @@ public class ComponentAuditedPropertiesReader extends AuditedPropertiesReader {
|
||||||
propertyData.setRelationTargetAuditMode( aud.targetAuditMode() );
|
propertyData.setRelationTargetAuditMode( aud.targetAuditMode() );
|
||||||
propertyData.setUsingModifiedFlag( checkUsingModifiedFlag( aud ) );
|
propertyData.setUsingModifiedFlag( checkUsingModifiedFlag( aud ) );
|
||||||
propertyData.setModifiedFlagName( MetadataTools.getModifiedFlagPropertyName( propertyName, modifiedFlagSuffix ) );
|
propertyData.setModifiedFlagName( MetadataTools.getModifiedFlagPropertyName( propertyName, modifiedFlagSuffix ) );
|
||||||
if( aud.modifiedColumnName() != null && !"".equals( aud.modifiedColumnName() ) ) {
|
if ( StringHelper.isNotEmpty( aud.modifiedColumnName() ) ) {
|
||||||
propertyData.setExplicitModifiedFlagName( aud.modifiedColumnName() );
|
propertyData.setExplicitModifiedFlagName( aud.modifiedColumnName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Locale;
|
||||||
*/
|
*/
|
||||||
public abstract class StringTools {
|
public abstract class StringTools {
|
||||||
public static boolean isEmpty(String s) {
|
public static boolean isEmpty(String s) {
|
||||||
return s == null || "".equals( s );
|
return s == null || s.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEmpty(Object o) {
|
public static boolean isEmpty(Object o) {
|
||||||
|
|
|
@ -14,8 +14,8 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.transaction.Status;
|
import javax.transaction.Status;
|
||||||
import javax.transaction.TransactionManager;
|
import javax.transaction.TransactionManager;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.envers.RevisionType;
|
import org.hibernate.envers.RevisionType;
|
||||||
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
|
import org.hibernate.envers.enhanced.SequenceIdRevisionEntity;
|
||||||
|
@ -24,8 +24,8 @@ import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionEntity;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionEntity;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity1;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity1;
|
||||||
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity2;
|
import org.hibernate.envers.test.entities.collection.MultipleCollectionRefEntity2;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
import org.hibernate.testing.SkipForDialects;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
|
@ -227,6 +227,12 @@ public class DetachedMultipleCollectionChangeTest extends BaseEnversJPAFunctiona
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialects( value = {
|
||||||
|
@SkipForDialect(value = CockroachDialect.class,
|
||||||
|
comment = "requires serial_normalization=sql_sequence setting"),
|
||||||
|
@SkipForDialect(value = Oracle8iDialect.class,
|
||||||
|
comment = "Oracle does not support identity key generation")
|
||||||
|
})
|
||||||
public void testAuditJoinTable() throws Exception {
|
public void testAuditJoinTable() throws Exception {
|
||||||
List<AuditJoinTableInfo> mceRe1AuditJoinTableInfos = getAuditJoinTableRows(
|
List<AuditJoinTableInfo> mceRe1AuditJoinTableInfos = getAuditJoinTableRows(
|
||||||
"MCE_RE1_AUD", "MCE_ID",
|
"MCE_RE1_AUD", "MCE_ID",
|
||||||
|
|
|
@ -41,7 +41,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
* @author Chris Cranford
|
* @author Chris Cranford
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey="HHH-13191")
|
@TestForIssue(jiraKey="HHH-13191")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsNoColumnInsert.class)
|
@RequiresDialectFeature({ DialectChecks.SupportsNoColumnInsert.class, DialectChecks.SupportsIdentityColumns.class })
|
||||||
public class IdentifierProxyJtaSessionClosedBeforeCommitTest extends BaseEnversJPAFunctionalTestCase {
|
public class IdentifierProxyJtaSessionClosedBeforeCommitTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
|
|
@ -44,17 +44,22 @@ public class BasicSametable extends BaseEnversJPAFunctionalTestCase {
|
||||||
public void initData() {
|
public void initData() {
|
||||||
EntityManager em = getEntityManager();
|
EntityManager em = getEntityManager();
|
||||||
|
|
||||||
// We need first to modify the columns in the middle (join table) to allow null values. Hbm2ddl doesn't seem
|
|
||||||
// to allow this.
|
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
Session session = (Session) em.getDelegate();
|
Session session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
||||||
|
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
||||||
|
em.getTransaction().commit();
|
||||||
|
em.clear();
|
||||||
|
|
||||||
|
// We need first to modify the columns in the middle (join table) to allow null values. Hbm2ddl doesn't seem
|
||||||
|
// to allow this.
|
||||||
|
em.getTransaction().begin();
|
||||||
|
session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
||||||
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
||||||
).executeUpdate();
|
).executeUpdate();
|
||||||
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
||||||
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
||||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
|
@ -17,6 +18,7 @@ import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
import org.hibernate.envers.test.entities.reventity.CustomDateRevEntity;
|
import org.hibernate.envers.test.entities.reventity.CustomDateRevEntity;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +71,7 @@ public class CustomDate extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testTimestamps() {
|
public void testTimestamps() {
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
||||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
|
@ -17,6 +18,7 @@ import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
import org.hibernate.envers.test.entities.reventity.CustomPropertyAccessRevEntity;
|
import org.hibernate.envers.test.entities.reventity.CustomPropertyAccessRevEntity;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,6 +68,7 @@ public class CustomPropertyAccess extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testTimestamps() {
|
public void testTimestamps() {
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
||||||
|
|
|
@ -13,12 +13,14 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
||||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
import org.hibernate.envers.test.Priority;
|
import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +70,7 @@ public class Inherited extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testTimestamps() {
|
public void testTimestamps() {
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
||||||
|
|
|
@ -9,12 +9,14 @@ package org.hibernate.envers.test.integration.revfordate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
import org.hibernate.envers.exception.RevisionDoesNotExistException;
|
||||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
import org.hibernate.envers.test.Priority;
|
import org.hibernate.envers.test.Priority;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,6 +83,7 @@ public class RevisionForDate extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testTimestamps() {
|
public void testTimestamps() {
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp2 ) ).intValue() == 1;
|
||||||
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
assert getAuditReader().getRevisionNumberForDate( new Date( timestamp3 ) ).intValue() == 2;
|
||||||
|
@ -88,6 +91,7 @@ public class RevisionForDate extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testEntitiesForTimestamps() {
|
public void testEntitiesForTimestamps() {
|
||||||
assert "x".equals( getAuditReader().find( StrTestEntity.class, id, new Date( timestamp2 ) ).getStr() );
|
assert "x".equals( getAuditReader().find( StrTestEntity.class, id, new Date( timestamp2 ) ).getStr() );
|
||||||
assert "y".equals( getAuditReader().find( StrTestEntity.class, id, new Date( timestamp3 ) ).getStr() );
|
assert "y".equals( getAuditReader().find( StrTestEntity.class, id, new Date( timestamp3 ) ).getStr() );
|
||||||
|
@ -103,6 +107,7 @@ public class RevisionForDate extends BaseEnversJPAFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "Fails because of int size")
|
||||||
public void testRevisionsForDates() {
|
public void testRevisionsForDates() {
|
||||||
AuditReader vr = getAuditReader();
|
AuditReader vr = getAuditReader();
|
||||||
|
|
||||||
|
|
|
@ -75,13 +75,18 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
Session session = (Session) em.getDelegate();
|
Session session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
||||||
|
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
||||||
|
em.getTransaction().commit();
|
||||||
|
em.clear();
|
||||||
|
|
||||||
|
em.getTransaction().begin();
|
||||||
|
session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
||||||
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
||||||
)
|
)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
||||||
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
|
|
|
@ -75,13 +75,18 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
Session session = (Session) em.getDelegate();
|
Session session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
session.createNativeQuery( "DROP TABLE children" ).executeUpdate();
|
||||||
|
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
||||||
|
em.getTransaction().commit();
|
||||||
|
em.clear();
|
||||||
|
|
||||||
|
em.getTransaction().begin();
|
||||||
|
session = (Session) em.getDelegate();
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
", child1_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() +
|
||||||
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
|
||||||
)
|
)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
session.createNativeQuery( "DROP TABLE children_AUD" ).executeUpdate();
|
|
||||||
session.createNativeQuery(
|
session.createNativeQuery(
|
||||||
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +
|
||||||
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
", REVEND " + getDialect().getTypeName( Types.INTEGER ) +
|
||||||
|
|
|
@ -14,23 +14,21 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
|
|
||||||
import org.hibernate.annotations.Cache;
|
import org.hibernate.annotations.Cache;
|
||||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.jcache.test.TestHelper;
|
|
||||||
import org.hibernate.mapping.Collection;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.schema.Action;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
import org.hibernate.tool.schema.Action;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -88,6 +86,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = CockroachDialect.class, comment = "does not support nested transactions")
|
||||||
public void testUpdateAndFlushThenRefresh() {
|
public void testUpdateAndFlushThenRefresh() {
|
||||||
final String BEFORE = "before";
|
final String BEFORE = "before";
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.testing;
|
package org.hibernate.testing;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.CockroachDialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
|
@ -285,7 +286,8 @@ abstract public class DialectChecks {
|
||||||
dialect instanceof DB2Dialect ||
|
dialect instanceof DB2Dialect ||
|
||||||
dialect instanceof PostgreSQL81Dialect ||
|
dialect instanceof PostgreSQL81Dialect ||
|
||||||
dialect instanceof SybaseDialect ||
|
dialect instanceof SybaseDialect ||
|
||||||
dialect instanceof MySQLDialect
|
dialect instanceof MySQLDialect ||
|
||||||
|
dialect instanceof CockroachDialect
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue