HHH-13724 Add CockroachDB dialects and configs for testing

This commit is contained in:
Rafi Shamim 2019-11-11 14:29:30 -05:00 committed by Andrea Boriero
parent 4df7986108
commit 4655bdbe12
73 changed files with 1034 additions and 227 deletions

View File

@ -63,6 +63,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 )

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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[]

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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();

View File

@ -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;
/** /**

View File

@ -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.CockroachDB192Dialect;
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,
CockroachDB192Dialect.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"
) )

View File

@ -120,6 +120,14 @@ 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'
],
] ]
} }

View File

@ -85,6 +85,7 @@ dependencies {
testRuntime( libraries.mssql ) testRuntime( libraries.mssql )
testRuntime( libraries.informix ) testRuntime( libraries.informix )
testRuntime( libraries.hana ) testRuntime( libraries.hana )
testRuntime( libraries.cockroachdb )
asciidoclet 'org.asciidoctor:asciidoclet:1.+' asciidoclet 'org.asciidoctor:asciidoclet:1.+'

View File

@ -114,6 +114,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',

View File

@ -0,0 +1,641 @@
/*
* 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;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Iterator;
import java.util.Map;
import org.hibernate.JDBCException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.PositionSubstringFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.dialect.identity.CockroachDB1920IdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.pagination.AbstractLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.dialect.pagination.LimitHelper;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
import org.hibernate.hql.spi.id.inline.InlineIdsInClauseBulkIdStrategy;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.PostgresUUIDType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor;
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
/**
* An SQL dialect for CockroachDB 19.2 and later. This is the first dialect for CockroachDB. It is largely adapted
* from the PostgreSQL dialects, with changes where appropriate.
*/
public class CockroachDB192Dialect extends Dialect {
private static final AbstractLimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
@Override
public String processSql(String sql, RowSelection selection) {
final boolean hasOffset = LimitHelper.hasFirstRow( selection );
return sql + (hasOffset ? " limit ? offset ?" : " limit ?");
}
@Override
public boolean supportsLimit() {
return true;
}
@Override
public boolean bindLimitParametersInReverseOrder() {
return true;
}
};
public CockroachDB192Dialect() {
super();
registerColumnType( Types.BIT, "bool" );
registerColumnType( Types.BIGINT, "int8" );
registerColumnType( Types.SMALLINT, "int2" );
registerColumnType( Types.TINYINT, "int2" );
registerColumnType( Types.INTEGER, "int4" );
registerColumnType( Types.CHAR, "char(1)" );
registerColumnType( Types.VARCHAR, "varchar($l)" );
registerColumnType( Types.FLOAT, "float4" );
registerColumnType( Types.DOUBLE, "float8" );
registerColumnType( Types.DATE, "date" );
registerColumnType( Types.TIME, "time" );
registerColumnType( Types.TIMESTAMP, "timestamp" );
registerColumnType( Types.VARBINARY, "bytea" );
registerColumnType( Types.BINARY, "bytea" );
registerColumnType( Types.LONGVARCHAR, "text" );
registerColumnType( Types.LONGVARBINARY, "bytea" );
registerColumnType( Types.CLOB, "text" );
registerColumnType( Types.BLOB, "bytea" );
registerColumnType( Types.NUMERIC, "numeric($p, $s)" );
registerColumnType( Types.OTHER, "uuid" );
registerColumnType( Types.JAVA_OBJECT, "json" );
registerFunction( "abs", new StandardSQLFunction("abs") );
registerFunction( "sign", new StandardSQLFunction("sign", StandardBasicTypes.INTEGER) );
registerFunction( "acos", new StandardSQLFunction("acos", StandardBasicTypes.DOUBLE) );
registerFunction( "asin", new StandardSQLFunction("asin", StandardBasicTypes.DOUBLE) );
registerFunction( "atan", new StandardSQLFunction("atan", StandardBasicTypes.DOUBLE) );
registerFunction( "cos", new StandardSQLFunction("cos", StandardBasicTypes.DOUBLE) );
registerFunction( "cot", new StandardSQLFunction("cot", StandardBasicTypes.DOUBLE) );
registerFunction( "exp", new StandardSQLFunction("exp", StandardBasicTypes.DOUBLE) );
registerFunction( "ln", new StandardSQLFunction("ln", StandardBasicTypes.DOUBLE) );
registerFunction( "log", new StandardSQLFunction("log", StandardBasicTypes.DOUBLE) );
registerFunction( "sin", new StandardSQLFunction("sin", StandardBasicTypes.DOUBLE) );
registerFunction( "sqrt", new StandardSQLFunction("sqrt", StandardBasicTypes.DOUBLE) );
registerFunction( "cbrt", new StandardSQLFunction("cbrt", StandardBasicTypes.DOUBLE) );
registerFunction( "tan", new StandardSQLFunction("tan", StandardBasicTypes.DOUBLE) );
registerFunction( "radians", new StandardSQLFunction("radians", StandardBasicTypes.DOUBLE) );
registerFunction( "degrees", new StandardSQLFunction("degrees", StandardBasicTypes.DOUBLE) );
registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.DOUBLE) );
registerFunction( "round", new StandardSQLFunction("round") );
registerFunction( "trunc", new StandardSQLFunction("trunc") );
registerFunction( "ceil", new StandardSQLFunction("ceil") );
registerFunction( "floor", new StandardSQLFunction("floor") );
registerFunction( "chr", new StandardSQLFunction("chr", StandardBasicTypes.CHARACTER) );
registerFunction( "lower", new StandardSQLFunction("lower") );
registerFunction( "upper", new StandardSQLFunction("upper") );
registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) );
registerFunction( "initcap", new StandardSQLFunction("initcap") );
registerFunction( "quote_ident", new StandardSQLFunction("quote_ident", StandardBasicTypes.STRING) );
registerFunction( "quote_literal", new StandardSQLFunction("quote_literal", StandardBasicTypes.STRING) );
registerFunction( "md5", new StandardSQLFunction("md5", StandardBasicTypes.STRING) );
registerFunction( "ascii", new StandardSQLFunction("ascii", StandardBasicTypes.INTEGER) );
registerFunction( "char_length", new StandardSQLFunction("char_length", StandardBasicTypes.LONG) );
registerFunction( "bit_length", new StandardSQLFunction("bit_length", StandardBasicTypes.LONG) );
registerFunction( "octet_length", new StandardSQLFunction("octet_length", StandardBasicTypes.LONG) );
registerFunction( "age", new StandardSQLFunction("age") );
registerFunction( "current_date", new NoArgSQLFunction("current_date", StandardBasicTypes.DATE, false) );
registerFunction( "current_timestamp", new NoArgSQLFunction("current_timestamp", StandardBasicTypes.TIMESTAMP, false) );
registerFunction( "date_trunc", new StandardSQLFunction( "date_trunc", StandardBasicTypes.TIMESTAMP ) );
registerFunction( "now", new NoArgSQLFunction("now", StandardBasicTypes.TIMESTAMP) );
registerFunction( "current_user", new NoArgSQLFunction("current_user", StandardBasicTypes.STRING, false) );
registerFunction( "session_user", new NoArgSQLFunction("session_user", StandardBasicTypes.STRING, false) );
registerFunction( "user", new NoArgSQLFunction("user", StandardBasicTypes.STRING, false) );
registerFunction( "current_database", new NoArgSQLFunction("current_database", StandardBasicTypes.STRING, true) );
registerFunction( "current_schema", new NoArgSQLFunction("current_schema", StandardBasicTypes.STRING, true) );
registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "(","||",")" ) );
registerFunction( "locate", new PositionSubstringFunction() );
registerFunction( "str", new SQLFunctionTemplate(StandardBasicTypes.STRING, "cast(?1 as varchar)") );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
}
@Override
public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
SqlTypeDescriptor descriptor;
switch (sqlCode) {
case Types.BLOB: {
// Make BLOBs use byte[] storage.
descriptor = VarbinaryTypeDescriptor.INSTANCE;
break;
}
case Types.CLOB: {
// Make CLOBs use string storage.
descriptor = VarcharTypeDescriptor.INSTANCE;
break;
}
default: {
descriptor = super.getSqlTypeDescriptorOverride(sqlCode);
break;
}
}
return descriptor;
}
@Override
public String getAddColumnString() {
return "add column";
}
@Override
public String getSequenceNextValString(String sequenceName) {
return "select " + getSelectSequenceNextValString( sequenceName );
}
@Override
public String getSelectSequenceNextValString(String sequenceName) {
return "nextval ('" + sequenceName + "')";
}
@Override
public String getCreateSequenceString(String sequenceName) {
//starts with 1, implicitly
return "create sequence " + sequenceName;
}
@Override
public String getCascadeConstraintsString() {
return " cascade";
}
@Override
public boolean dropConstraints() {
return true;
}
@Override
public boolean supportsSequences() {
return true;
}
@Override
public String getQuerySequencesString() {
return "select * from information_schema.sequences";
}
@Override
public LimitHandler getLimitHandler() {
return LIMIT_HANDLER;
}
@Override
public boolean supportsLimit() {
return true;
}
@Override
public String getLimitString(String sql, boolean hasOffset) {
return sql + (hasOffset ? " limit ? offset ?" : " limit ?");
}
@Override
public boolean bindLimitParametersInReverseOrder() {
return true;
}
@Override
public String getForUpdateString(String aliases) {
return getForUpdateString() + " of " + aliases;
}
@Override
public String getForUpdateString(String aliases, LockOptions lockOptions) {
/*
* Parent's implementation for (aliases, lockOptions) ignores aliases.
*/
if ( "".equals( aliases ) ) {
LockMode lockMode = lockOptions.getLockMode();
final Iterator<Map.Entry<String, LockMode>> itr = lockOptions.getAliasLockIterator();
while ( itr.hasNext() ) {
// seek the highest lock mode
final Map.Entry<String, LockMode> entry = itr.next();
final LockMode lm = entry.getValue();
if ( lm.greaterThan( lockMode ) ) {
aliases = entry.getKey();
}
}
}
LockMode lockMode = lockOptions.getAliasSpecificLockMode( aliases );
if (lockMode == null ) {
lockMode = lockOptions.getLockMode();
}
switch ( lockMode ) {
case UPGRADE:
return getForUpdateString(aliases);
case PESSIMISTIC_READ:
return getReadLockString( aliases, lockOptions.getTimeOut() );
case PESSIMISTIC_WRITE:
return getWriteLockString( aliases, lockOptions.getTimeOut() );
case UPGRADE_NOWAIT:
case FORCE:
case PESSIMISTIC_FORCE_INCREMENT:
return getForUpdateNowaitString(aliases);
case UPGRADE_SKIPLOCKED:
return getForUpdateSkipLockedString(aliases);
default:
return "";
}
}
@Override
public String getNoColumnsInsertString() {
return "default values";
}
@Override
public String getCaseInsensitiveLike(){
return "ilike";
}
@Override
public boolean supportsCaseInsensitiveLike() {
return true;
}
@Override
public String getNativeIdentifierGeneratorStrategy() {
return "sequence";
}
@Override
public boolean supportsOuterJoinForUpdate() {
return false;
}
@Override
public boolean useInputStreamToInsertBlob() {
return false;
}
@Override
public boolean supportsUnionAll() {
return true;
}
@Override
public String getSelectClauseNullString(int sqlType) {
String typeName = getTypeName( sqlType, 1, 1, 0 );
//trim off the length/precision/scale
final int loc = typeName.indexOf( '(' );
if ( loc > -1 ) {
typeName = typeName.substring( 0, loc );
}
return "null::" + typeName;
}
@Override
public boolean supportsCommentOn() {
return true;
}
@Override
public boolean supportsCurrentTimestampSelection() {
return true;
}
@Override
public boolean isCurrentTimestampSelectStringCallable() {
return false;
}
@Override
public String getCurrentTimestampSelectString() {
return "select now()";
}
@Override
public boolean requiresParensForTupleDistinctCounts() {
return true;
}
@Override
public String toBooleanValueString(boolean bool) {
return bool ? "true" : "false";
}
@Override
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
}
/**
* Constraint-name extractor for CockroachDB constraint violation exceptions.
*/
private static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
@Override
protected String doExtractConstraintName(SQLException sqle) throws NumberFormatException {
final int sqlState = Integer.parseInt( JdbcExceptionHelper.extractSqlState( sqle ) );
switch (sqlState) {
// CHECK VIOLATION
case 23514: return extractUsingTemplate( "failed to satisfy CHECK constraint ","\"", sqle.getMessage() );
// UNIQUE VIOLATION
case 23505: return extractUsingTemplate( "violates unique constraint \"","\"", sqle.getMessage() );
// FOREIGN KEY VIOLATION
case 23503: return extractUsingTemplate( "violates foreign key constraint \"","\"", sqle.getMessage() );
// NOT NULL VIOLATION
case 23502: return extractUsingTemplate( "null value in column \"","\" violates not-null constraint", sqle.getMessage() );
// TODO: RESTRICT VIOLATION
case 23001: return null;
// ALL OTHER
default: return null;
}
}
};
@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
return new SQLExceptionConversionDelegate() {
@Override
public JDBCException convert(SQLException sqlException, String message, String sql) {
final String sqlState = JdbcExceptionHelper.extractSqlState( sqlException );
if ( "40P01".equals( sqlState ) ) {
// DEADLOCK DETECTED
return new LockAcquisitionException( message, sqlException, sql );
}
if ( "55P03".equals( sqlState ) ) {
// LOCK NOT AVAILABLE
return new PessimisticLockException( message, sqlException, sql );
}
// returning null allows other delegates to operate
return null;
}
};
}
@Override
public boolean supportsPooledSequences() {
return true;
}
@Override
protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) {
if ( initialValue < 0 && incrementSize > 0 ) {
return
String.format(
"%s minvalue %d start %d increment %d",
getCreateSequenceString( sequenceName ),
initialValue,
initialValue,
incrementSize
);
}
else if ( initialValue > 0 && incrementSize < 0 ) {
return
String.format(
"%s maxvalue %d start %d increment %d",
getCreateSequenceString( sequenceName ),
initialValue,
initialValue,
incrementSize
);
}
else {
return
String.format(
"%s start %d increment %d",
getCreateSequenceString( sequenceName ),
initialValue,
incrementSize
);
}
}
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public boolean supportsEmptyInList() {
return false;
}
@Override
public boolean supportsExpectedLobUsagePattern() {
return false;
}
@Override
public boolean supportsLobValueChangePropogation() {
return false;
}
@Override
public boolean supportsUnboundedLobLocatorMaterialization() {
return false;
}
@Override
public boolean supportsRowValueConstructorSyntax() {
return true;
}
@Override
public boolean qualifyIndexName() {
return false;
}
@Override
public boolean supportsNationalizedTypes() {
return false;
}
@Override
public boolean supportsJdbcConnectionLobCreation(DatabaseMetaData databaseMetaData) {
return false;
}
@Override
public boolean supportsSelectAliasInGroupByClause() {
return true;
}
@Override
public boolean supportsIfExistsBeforeTableName() {
return true;
}
@Override
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
super.contributeTypes( typeContributions, serviceRegistry );
// CockroachDB UUID type is the same as PostgreSQL.
typeContributions.contributeType( PostgresUUIDType.INSTANCE );
}
@Override
public String getDropSequenceString(String sequenceName) {
return "drop sequence if exists " + sequenceName;
}
@Override
public boolean supportsValuesList() {
return true;
}
public boolean supportsRowValueConstructorSyntaxInInList() {
return true;
}
@Override
public boolean supportsPartitionBy() {
return true;
}
@Override
public boolean supportsNonQueryWithCTE() {
return true;
}
@Override
public boolean supportsIfExistsAfterAlterTable() {
return true;
}
@Override
public String getForUpdateString() {
return " for update";
}
@Override
public String getWriteLockString(int timeout) {
if ( timeout == LockOptions.SKIP_LOCKED ) {
return getForUpdateSkipLockedString();
}
else {
return super.getWriteLockString( timeout );
}
}
@Override
public String getWriteLockString(String aliases, int timeout) {
if ( timeout == LockOptions.SKIP_LOCKED ) {
return getForUpdateSkipLockedString( aliases );
}
else {
return super.getWriteLockString( aliases, timeout );
}
}
@Override
public String getReadLockString(int timeout) {
if ( timeout == LockOptions.SKIP_LOCKED ) {
return " for share skip locked";
}
else {
return super.getReadLockString( timeout );
}
}
@Override
public String getReadLockString(String aliases, int timeout) {
if ( timeout == LockOptions.SKIP_LOCKED ) {
return String.format( " for share of %s skip locked", aliases );
}
else {
return super.getReadLockString( aliases, timeout );
}
}
@Override
public String getForUpdateSkipLockedString() {
return " for update skip locked";
}
@Override
public String getForUpdateSkipLockedString(String aliases) {
return getForUpdateString() + " of " + aliases + " skip locked";
}
@Override
public String getForUpdateNowaitString() {
return getForUpdateString() + " nowait ";
}
@Override
public String getForUpdateNowaitString(String aliases) {
return getForUpdateString( aliases ) + " nowait ";
}
@Override
public boolean supportsLockTimeouts() {
return false;
}
@Override
public boolean supportsSkipLocked() {
// CockroachDB 19.2.0 doesn't support this: https://github.com/cockroachdb/cockroach/issues/40476
// A later version will add support, so the syntax for locks is added above.
return false;
}
@Override
public boolean supportsNoWait() {
// CockroachDB 19.2.0 doesn't support this: https://github.com/cockroachdb/cockroach/issues/40476
// A later version will add support, so the syntax for locks is added above.
return false;
}
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return new CockroachDB1920IdentityColumnSupport();
}
@Override
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() {
// A later version of CockroachDB will support the same temp table syntax as PostgreSQL.
return new InlineIdsInClauseBulkIdStrategy();
}
@Override
public boolean doesReadCommittedCauseWritersToBlockReaders() {
return true;
}
@Override
public boolean canCreateSchema() {
return false;
}
}

View File

@ -0,0 +1,23 @@
/*
* 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;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.type.StandardBasicTypes;
/**
* An SQL dialect for CockroachDB 20.1 and later. Adds support for a few date/time functions.
*/
public class CockroachDB201Dialect extends CockroachDB192Dialect {
public CockroachDB201Dialect() {
super();
registerFunction( "current_time", new NoArgSQLFunction("current_time", StandardBasicTypes.TIME, false) );
registerFunction( "localtime", new NoArgSQLFunction("localtime", StandardBasicTypes.TIME, false) );
registerFunction( "localtimestamp", new NoArgSQLFunction("localtimestamp", StandardBasicTypes.TIMESTAMP, false) );
registerFunction( "timeofday", new NoArgSQLFunction("timeofday", StandardBasicTypes.STRING) );
}
}

View File

@ -28,7 +28,6 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Interceptor; import org.hibernate.Interceptor;
@ -85,7 +84,6 @@ import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.io.StreamCopier; import org.hibernate.internal.util.io.StreamCopier;
import org.hibernate.loader.BatchLoadSizingStrategy; import org.hibernate.loader.BatchLoadSizingStrategy;
@ -3052,5 +3050,4 @@ public abstract class Dialect implements ConversionContext {
public boolean supportsSelectAliasInGroupByClause() { public boolean supportsSelectAliasInGroupByClause() {
return false; return false;
} }
} }

View File

@ -648,5 +648,4 @@ public class PostgreSQL81Dialect extends Dialect {
public boolean supportsSelectAliasInGroupByClause() { public boolean supportsSelectAliasInGroupByClause() {
return true; return true;
} }
} }

View File

@ -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;
}
}

View File

@ -92,7 +92,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();
} }
@ -102,11 +102,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 );
@ -129,6 +139,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() );
} }

View File

@ -19,6 +19,8 @@ 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.CockroachDB192Dialect;
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 +62,7 @@ public class ReadWriteCacheTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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 +139,7 @@ public class ReadWriteCacheTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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;

View File

@ -15,7 +15,6 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
@ -27,16 +26,14 @@ import org.hibernate.id.SequenceMismatchStrategy;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule; import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable; import org.hibernate.testing.logger.Triggerable;
import org.jboss.logging.Logger;
import org.junit.Rule; import org.junit.Rule;
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;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;

View File

@ -18,7 +18,7 @@ import javax.persistence.criteria.CriteriaQuery;
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.CockroachDB192Dialect;
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;
@ -37,9 +37,9 @@ import org.hibernate.jpa.test.metamodel.Spouse;
import org.hibernate.metamodel.internal.MetamodelImpl; import org.hibernate.metamodel.internal.MetamodelImpl;
import org.hibernate.query.criteria.internal.CriteriaBuilderImpl; import org.hibernate.query.criteria.internal.CriteriaBuilderImpl;
import org.hibernate.query.criteria.internal.predicate.ComparisonPredicate; import org.hibernate.query.criteria.internal.predicate.ComparisonPredicate;
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 +232,7 @@ public class QueryBuilderTest extends BaseEntityManagerFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.class, strictMatching = true)
public void testDateTimeFunctions() { public void testDateTimeFunctions() {
EntityManager em = getOrCreateEntityManager(); EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin(); em.getTransaction().begin();

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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();

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.class )
public void testFindWithTimeoutHint() { public void testFindWithTimeoutHint() {
final Lock lock = new Lock(); final Lock lock = new Lock();
lock.setName( "name" ); lock.setName( "name" );

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.class )
public void testPessimisticForcedIncrementSpecific() { public void testPessimisticForcedIncrementSpecific() {
EntityManager em = getOrCreateEntityManager(); EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin(); em.getTransaction().begin();

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.class )
public void testStatementIsClosed() { public void testStatementIsClosed() {
TransactionUtil.doInJPA( this::entityManagerFactory, em1 -> { TransactionUtil.doInJPA( this::entityManagerFactory, em1 -> {

View File

@ -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.CockroachDB201Dialect;
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;
@ -116,7 +117,7 @@ public class NativeQueryOrdinalParametersTest extends BaseEntityManagerFunctiona
@Test @Test
@TestForIssue(jiraKey = "HHH-12532") @TestForIssue(jiraKey = "HHH-12532")
@RequiresDialect(PostgreSQL82Dialect.class) @RequiresDialect({ PostgreSQL82Dialect.class, CockroachDB201Dialect.class })
public void testCteNativeQueryOrdinalParameter() { public void testCteNativeQueryOrdinalParameter() {
Node root1 = new Node(); Node root1 = new Node();

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.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 {

View File

@ -23,6 +23,7 @@ import org.hibernate.Transaction;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl; import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.dialect.CockroachDB192Dialect;
import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQL9Dialect; import org.hibernate.dialect.PostgreSQL9Dialect;
@ -118,6 +119,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 = CockroachDB192Dialect.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();
@ -203,6 +205,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 = CockroachDB192Dialect.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();

View File

@ -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.CockroachDB192Dialect;
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, CockroachDB192Dialect.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",

View File

@ -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

View File

@ -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

View File

@ -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.CockroachDB192Dialect;
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 CockroachDB192Dialect){
// 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]

View File

@ -30,6 +30,7 @@ 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.HANACloudColumnStoreDialect; import org.hibernate.dialect.HANACloudColumnStoreDialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.internal.ast.tree.JavaConstantNode; import org.hibernate.hql.internal.ast.tree.JavaConstantNode;
import org.hibernate.internal.util.ConfigHelper; import org.hibernate.internal.util.ConfigHelper;
@ -47,6 +48,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;
@ -111,7 +115,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
@ -162,7 +167,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 );
@ -191,7 +197,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 );

View File

@ -6,30 +6,6 @@
*/ */
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.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Query; import org.hibernate.Query;
@ -40,24 +16,7 @@ import org.hibernate.Transaction;
import org.hibernate.TypeMismatchException; import org.hibernate.TypeMismatchException;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.*;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.Sybase11Dialect;
import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TeradataDialect;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory; import org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory;
import org.hibernate.hql.internal.ast.QuerySyntaxException; import org.hibernate.hql.internal.ast.QuerySyntaxException;
@ -88,6 +47,32 @@ import org.hibernate.type.ManyToOneType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.junit.Test; import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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;
/** /**
* Tests the integration of the new AST parser into the loading of query results using * Tests the integration of the new AST parser into the loading of query results using
* the Hibernate persisters and loaders. * the Hibernate persisters and loaders.
@ -976,6 +961,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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();
@ -2948,6 +2934,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943")
@SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"}) @SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"})
public void testSelectExpressions() { public void testSelectExpressions() {
createTestBaseData(); createTestBaseData();
@ -3281,6 +3268,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.class, strictMatching = true)
public void testStandardFunctions() throws Exception { public void testStandardFunctions() throws Exception {
Session session = openSession(); Session session = openSession();
Transaction t = session.beginTransaction(); Transaction t = session.beginTransaction();
@ -3841,7 +3829,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 CockroachDB192Dialect ) {
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24"; hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
} }
else { else {
@ -3850,7 +3839,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 CockroachDB192Dialect ) {
hql = "select bit_length(str(a.bodyWeight)) from Animal a"; hql = "select bit_length(str(a.bodyWeight)) from Animal a";
} }
else { else {

View File

@ -18,6 +18,7 @@ import org.hibernate.QueryException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.dialect.CockroachDB192Dialect;
import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
@ -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,
CockroachDB192Dialect.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 CockroachDB192Dialect ) {
// 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" );
} }
@ -890,6 +896,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 +1077,7 @@ public class HQLTest extends QueryTranslatorTestCase {
} }
@Test @Test
@SkipForDialect(CockroachDB192Dialect.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" );
} }

View File

@ -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();

View File

@ -11,14 +11,12 @@ package org.hibernate.test.legacy;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.dialect.CockroachDB192Dialect;
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.id.PostInsertIdentifierGenerator;
import org.hibernate.testing.DialectCheck; import org.hibernate.testing.DialectCheck;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
@ -47,7 +45,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, CockroachDB192Dialect.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();

View File

@ -45,24 +45,7 @@ import org.hibernate.criterion.Example;
import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order; import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.*;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.DerbyDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.InterbaseDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PointbaseDialect;
import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SAPDBDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TeradataDialect;
import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
@ -81,8 +64,6 @@ import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.junit.Test; import org.junit.Test;
import org.jboss.logging.Logger;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@ -391,6 +372,7 @@ public class FooBarTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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();
@ -2293,6 +2275,7 @@ 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 CockroachDB192Dialect ) &&
!( 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(
@ -2368,7 +2351,10 @@ 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 CockroachDB192Dialect) {
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();

View File

@ -13,6 +13,7 @@ import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.CockroachDB192Dialect;
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;
@ -38,8 +39,11 @@ public abstract class LegacyTestCase extends BaseCoreFunctionalTestCase {
} }
protected boolean supportsLockingNullableSideOfJoin(Dialect dialect) { protected boolean supportsLockingNullableSideOfJoin(Dialect dialect) {
// db2 and pgsql do *NOT* // db2. pgsql, and cockroachdb 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 ) ||
CockroachDB192Dialect.class.isInstance( dialect ));
} }
protected static String extractFromSystem(String systemPropertyName) { protected static String extractFromSystem(String systemPropertyName) {

View File

@ -21,11 +21,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Example; import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.*;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MckoiDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.SAPDBDialect;
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 +192,7 @@ public class MasterDetailTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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 +217,7 @@ public class MasterDetailTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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();

View File

@ -8,10 +8,6 @@
//$Id: MultiTableTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $ //$Id: MultiTableTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
package org.hibernate.test.legacy; package org.hibernate.test.legacy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
@ -22,7 +18,6 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -30,6 +25,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.CockroachDB192Dialect;
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;
@ -37,6 +33,10 @@ import org.hibernate.jdbc.Work;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public class MultiTableTest extends LegacyTestCase { public class MultiTableTest extends LegacyTestCase {
@Override @Override
@ -249,6 +249,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect( value = CockroachDB192Dialect.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();
@ -392,6 +393,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect( value = CockroachDB192Dialect.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();
@ -515,6 +517,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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();
@ -587,6 +590,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.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();

View File

@ -17,6 +17,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.hibernate.dialect.*;
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.SkipForDialect;
@ -33,12 +34,6 @@ import org.hibernate.ReplicationMode;
import org.hibernate.Session; 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.H2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.IngresDialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.TeradataDialect;
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;
@ -1095,6 +1090,7 @@ public class ParentChildTest extends LegacyTestCase {
} }
@Test @Test
@SkipForDialect( value = CockroachDB192Dialect.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 +1205,8 @@ public class ParentChildTest extends LegacyTestCase {
s.close(); s.close();
} }
@Test @Test
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "Uses READ_COMMITTED isolation")
public void testLoadAfterNonExists() throws HibernateException, SQLException { 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 ) ) {

View File

@ -16,10 +16,9 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.dialect.CockroachDB192Dialect;
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 +33,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, CockroachDB192Dialect.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 +89,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 +116,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 +134,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 +152,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(

View File

@ -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;

View File

@ -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;

View File

@ -14,6 +14,7 @@ import javax.persistence.LockModeType;
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.CockroachDB192Dialect;
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;
@ -201,6 +202,7 @@ public class LockModeTest extends BaseCoreFunctionalTestCase {
@Test @Test
@TestForIssue(jiraKey = "HHH-12257") @TestForIssue(jiraKey = "HHH-12257")
@SkipForDialect( value = CockroachDB192Dialect.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 );

View File

@ -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;

View File

@ -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.CockroachDB192Dialect;
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 CockroachDB192Dialect ){
// 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 CockroachDB192Dialect ){
// 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 CockroachDB192Dialect ){
// 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 CockroachDB192Dialect ) {
// See issue HHH-10693 // See issue HHH-10693
assertSame( CharacterType.INSTANCE, prop.getType() ); assertSame( CharacterType.INSTANCE, prop.getType() );
} }

View File

@ -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.CockroachDB192Dialect;
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 CockroachDB192Dialect){
// 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 CockroachDB192Dialect ){
assertSame( CharacterType.INSTANCE, nameAttribute.getType() ); assertSame( CharacterType.INSTANCE, nameAttribute.getType() );
}else { }else {
assertSame( CharacterNCharType.INSTANCE, nameAttribute.getType() ); assertSame( CharacterNCharType.INSTANCE, nameAttribute.getType() );

View File

@ -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.CockroachDB192Dialect;
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 CockroachDB192Dialect && ((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 );
} }
} }

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -12,7 +12,6 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Index; import javax.persistence.Index;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -22,13 +21,12 @@ 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.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
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.BaseNonConfigCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.hibernate.tool.schema.TargetType;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View File

@ -20,8 +20,10 @@ import org.hibernate.boot.MetadataSources;
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.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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;

View File

@ -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.CockroachDB192Dialect;
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 CockroachDB192Dialect) {
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;

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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;

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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();

View File

@ -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 ( CockroachDB192Dialect.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 )

View File

@ -53,10 +53,15 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
doInHibernate( doInHibernate(
this::sessionFactory, session -> { this::sessionFactory, session -> {
session.createSQLQuery( "drop table MATERIAL_RATINGS" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" )).executeUpdate();
session.createSQLQuery( "drop table BUILDING_RATINGS" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "BUILDING_RATINGS" )).executeUpdate();
session.createSQLQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" )).executeUpdate();
session.createSQLQuery( "drop table MAIN_TABLE" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
}
);
doInHibernate(
this::sessionFactory, session -> {
session.createSQLQuery( session.createSQLQuery(
"create table MAIN_TABLE( " + "create table MAIN_TABLE( " +

View File

@ -50,7 +50,12 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
doInHibernate( doInHibernate(
this::sessionFactory, session -> { this::sessionFactory, session -> {
session.createSQLQuery( "DROP TABLE MAIN_TABLE" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
}
);
doInHibernate(
this::sessionFactory, session -> {
session.createSQLQuery( session.createSQLQuery(
"create table MAIN_TABLE( " + "create table MAIN_TABLE( " +

View File

@ -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.createSQLQuery( "drop table MATERIAL_RATINGS" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" )).executeUpdate();
session.createSQLQuery( "drop table BUILDING_RATINGS" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "BUILDING_RATINGS" )).executeUpdate();
session.createSQLQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" )).executeUpdate();
session.createSQLQuery( "drop table MAIN_TABLE" ).executeUpdate(); session.createSQLQuery( getDialect().getDropTableString( "MAIN_TABLE" )).executeUpdate();
}
);
doInHibernate(
this::sessionFactory, session -> {
session.createSQLQuery( session.createSQLQuery(
"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 -> {

View File

@ -41,11 +41,15 @@ public class LazyManyToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCa
public void setup() { public void setup() {
doInHibernate( doInHibernate(
this::sessionFactory, session -> { this::sessionFactory, session -> {
session.createSQLQuery( getDialect().getDropTableString( "MATERIAL_RATINGS" ) ).executeUpdate();
session.createSQLQuery( getDialect().getDropTableString( "BUILDING_RATINGS" ) ).executeUpdate();
session.createSQLQuery( getDialect().getDropTableString( "ASSOCIATION_TABLE" ) ).executeUpdate();
session.createSQLQuery( getDialect().getDropTableString( "MAIN_TABLE" ) ).executeUpdate();
}
);
session.createSQLQuery( "drop table MATERIAL_RATINGS" ).executeUpdate(); doInHibernate(
session.createSQLQuery( "drop table BUILDING_RATINGS" ).executeUpdate(); this::sessionFactory, session -> {
session.createSQLQuery( "drop table ASSOCIATION_TABLE" ).executeUpdate();
session.createSQLQuery( "drop table MAIN_TABLE" ).executeUpdate();
session.createSQLQuery( session.createSQLQuery(
"create table MAIN_TABLE( " + "create table MAIN_TABLE( " +

View File

@ -41,9 +41,12 @@ public class LazyOneToManyNonUniqueIdWhereTest extends BaseCoreFunctionalTestCas
public void setup() { public void setup() {
doInHibernate( doInHibernate(
this::sessionFactory, session -> { this::sessionFactory, session -> {
session.createSQLQuery( getDialect().getDropTableString( "MAIN_TABLE" ) ).executeUpdate();
}
);
session.createSQLQuery( "DROP TABLE MAIN_TABLE" ).executeUpdate(); doInHibernate(
this::sessionFactory, session -> {
session.createSQLQuery( session.createSQLQuery(
"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, " +

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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",

View File

@ -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() {

View File

@ -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.createSQLQuery( "DROP TABLE children" ).executeUpdate(); session.createSQLQuery( "DROP TABLE children" ).executeUpdate();
session.createSQLQuery( "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.createSQLQuery( session.createSQLQuery(
"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.createSQLQuery( "DROP TABLE children_AUD" ).executeUpdate();
session.createSQLQuery( session.createSQLQuery(
"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 ) +

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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;

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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;

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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;

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.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 = CockroachDB192Dialect.class, comment = "Fails because of int size")
public void testRevisionsForDates() { public void testRevisionsForDates() {
AuditReader vr = getAuditReader(); AuditReader vr = getAuditReader();

View File

@ -75,6 +75,12 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
em.getTransaction().begin(); em.getTransaction().begin();
Session session = (Session) em.getDelegate(); Session session = (Session) em.getDelegate();
session.createSQLQuery( "DROP TABLE children" ).executeUpdate(); session.createSQLQuery( "DROP TABLE children" ).executeUpdate();
session.createSQLQuery( "DROP TABLE children_AUD" ).executeUpdate();
em.getTransaction().commit();
em.clear();
em.getTransaction().begin();
session = (Session) em.getDelegate();
session session
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) + "CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
@ -82,7 +88,6 @@ public class ValidityAuditStrategyRevEndTestCustomRevEnt extends BaseEnversJPAFu
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )" ", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
) )
.executeUpdate(); .executeUpdate();
session.createSQLQuery( "DROP TABLE children_AUD" ).executeUpdate();
session session
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" + "CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +

View File

@ -75,6 +75,12 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
em.getTransaction().begin(); em.getTransaction().begin();
Session session = (Session) em.getDelegate(); Session session = (Session) em.getDelegate();
session.createSQLQuery( "DROP TABLE children" ).executeUpdate(); session.createSQLQuery( "DROP TABLE children" ).executeUpdate();
session.createSQLQuery( "DROP TABLE children_AUD" ).executeUpdate();
em.getTransaction().commit();
em.clear();
em.getTransaction().begin();
session = (Session) em.getDelegate();
session session
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) + "CREATE TABLE children ( parent_id " + getDialect().getTypeName( Types.INTEGER ) +
@ -82,7 +88,6 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )" ", child2_id " + getDialect().getTypeName( Types.INTEGER ) + getDialect().getNullColumnString() + " )"
) )
.executeUpdate(); .executeUpdate();
session.createSQLQuery( "DROP TABLE children_AUD" ).executeUpdate();
session session
.createSQLQuery( .createSQLQuery(
"CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" + "CREATE TABLE children_AUD ( REV " + getDialect().getTypeName( Types.INTEGER ) + " NOT NULL" +

View File

@ -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.CockroachDB192Dialect;
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 = CockroachDB192Dialect.class, comment = "does not support nested transactions")
public void testUpdateAndFlushThenRefresh() { public void testUpdateAndFlushThenRefresh() {
final String BEFORE = "before"; final String BEFORE = "before";

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.testing; package org.hibernate.testing;
import org.hibernate.dialect.CockroachDB192Dialect;
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 CockroachDB192Dialect
); );
} }
} }