Add version to @SkipDialect and @RequiresDialect and re-enabled additional tests
This commit is contained in:
parent
61cd51a4c8
commit
1a6b01a2a8
|
@ -32,6 +32,7 @@ import static org.hibernate.query.TemporalUnit.*;
|
||||||
* @author Seok Jeong Il
|
* @author Seok Jeong Il
|
||||||
*/
|
*/
|
||||||
public class CUBRIDDialect extends Dialect {
|
public class CUBRIDDialect extends Dialect {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a CUBRIDDialect
|
* Constructs a CUBRIDDialect
|
||||||
*/
|
*/
|
||||||
|
@ -87,6 +88,11 @@ public class CUBRIDDialect extends Dialect {
|
||||||
registerKeyword( "SEARCH" );
|
registerKeyword( "SEARCH" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -71,6 +71,11 @@ public class CacheDialect extends Dialect {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
||||||
import org.hibernate.dialect.sequence.PostgreSQLSequenceSupport;
|
import org.hibernate.dialect.sequence.PostgreSQLSequenceSupport;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
@ -33,9 +34,21 @@ public class CockroachDialect extends Dialect {
|
||||||
|
|
||||||
// * no support for java.sql.Clob
|
// * no support for java.sql.Clob
|
||||||
|
|
||||||
|
private int version;
|
||||||
|
|
||||||
public CockroachDialect() {
|
public CockroachDialect() {
|
||||||
|
this(192);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CockroachDialect(DialectResolutionInfo info) {
|
||||||
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public CockroachDialect(int version) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.version = version;
|
||||||
|
|
||||||
registerColumnType( Types.TINYINT, "smallint" ); //no tinyint
|
registerColumnType( Types.TINYINT, "smallint" ); //no tinyint
|
||||||
|
|
||||||
//no binary/varbinary
|
//no binary/varbinary
|
||||||
|
@ -57,6 +70,11 @@ public class CockroachDialect extends Dialect {
|
||||||
registerColumnType( Types.JAVA_OBJECT, "json" );
|
registerColumnType( Types.JAVA_OBJECT, "json" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry(queryEngine);
|
super.initializeFunctionRegistry(queryEngine);
|
||||||
|
|
|
@ -10,15 +10,13 @@ package org.hibernate.dialect;
|
||||||
* An SQL dialect for DB2 9.7.
|
* An SQL dialect for DB2 9.7.
|
||||||
*
|
*
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*
|
|
||||||
* @deprecated use {@code DB2Dialect(970)}
|
* @deprecated use {@code DB2Dialect(970)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class DB297Dialect extends DB2Dialect {
|
public class DB297Dialect extends DB2Dialect {
|
||||||
|
|
||||||
@Override
|
public DB297Dialect() {
|
||||||
int getVersion() {
|
super( 970 );
|
||||||
return 970;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,6 @@ public class DB2Dialect extends Dialect {
|
||||||
|
|
||||||
private LimitHandler limitHandler;
|
private LimitHandler limitHandler;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final UniqueDelegate uniqueDelegate;
|
private final UniqueDelegate uniqueDelegate;
|
||||||
|
|
||||||
public DB2Dialect(DialectResolutionInfo info) {
|
public DB2Dialect(DialectResolutionInfo info) {
|
||||||
|
@ -119,11 +115,17 @@ public class DB2Dialect extends Dialect {
|
||||||
: DB2LimitHandler.INSTANCE;
|
: DB2LimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public int getDefaultDecimalPrecision() {
|
||||||
//this is the maximum allowed in DB2
|
//this is the maximum allowed in DB2
|
||||||
return 31;
|
return 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -70,10 +70,6 @@ public class DerbyDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
public DerbyDialect(DialectResolutionInfo info) {
|
public DerbyDialect(DialectResolutionInfo info) {
|
||||||
|
@ -116,11 +112,17 @@ public class DerbyDialect extends Dialect {
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public int getDefaultDecimalPrecision() {
|
||||||
//this is the maximum allowed in Derby
|
//this is the maximum allowed in Derby
|
||||||
return 31;
|
return 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFloatPrecision() {
|
public int getFloatPrecision() {
|
||||||
return 23;
|
return 23;
|
||||||
|
|
|
@ -135,7 +135,6 @@ public abstract class Dialect implements ConversionContext {
|
||||||
|
|
||||||
private DefaultSizeStrategy defaultSizeStrategy;
|
private DefaultSizeStrategy defaultSizeStrategy;
|
||||||
|
|
||||||
|
|
||||||
// constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// constructors and factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
protected Dialect() {
|
protected Dialect() {
|
||||||
|
@ -240,6 +239,8 @@ public abstract class Dialect implements ConversionContext {
|
||||||
: size;
|
: size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract int getVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the given registry with any dialect-specific functions.
|
* Initialize the given registry with any dialect-specific functions.
|
||||||
*
|
*
|
||||||
|
|
|
@ -66,10 +66,6 @@ public class FirebirdDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
public int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FirebirdDialect() {
|
public FirebirdDialect() {
|
||||||
this(250);
|
this(250);
|
||||||
}
|
}
|
||||||
|
@ -132,6 +128,11 @@ public class FirebirdDialect extends Dialect {
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return getVersion() < 300
|
return getVersion() < 300
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class H2Dialect extends Dialect {
|
||||||
|
|
||||||
private final boolean cascadeConstraints;
|
private final boolean cascadeConstraints;
|
||||||
|
|
||||||
|
private final int version;
|
||||||
|
|
||||||
private final SequenceInformationExtractor sequenceInformationExtractor;
|
private final SequenceInformationExtractor sequenceInformationExtractor;
|
||||||
private final String querySequenceString;
|
private final String querySequenceString;
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ public class H2Dialect extends Dialect {
|
||||||
|
|
||||||
public H2Dialect(int version, int buildId) {
|
public H2Dialect(int version, int buildId) {
|
||||||
super();
|
super();
|
||||||
|
this.version = version;
|
||||||
//TODO: actually I think all builds of 1.4 support OFFSET FETCH
|
//TODO: actually I think all builds of 1.4 support OFFSET FETCH
|
||||||
limitHandler = version > 140 || version == 140 && buildId >= 199
|
limitHandler = version > 140 || version == 140 && buildId >= 199
|
||||||
? OffsetFetchLimitHandler.INSTANCE
|
? OffsetFetchLimitHandler.INSTANCE
|
||||||
|
@ -114,6 +116,11 @@ public class H2Dialect extends Dialect {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -27,85 +27,10 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
* @deprecated use HANAColumnStoreDialect(400)
|
* @deprecated use HANAColumnStoreDialect(400)
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class HANACloudColumnStoreDialect extends AbstractHANADialect {
|
public class HANACloudColumnStoreDialect extends HANAColumnStoreDialect {
|
||||||
|
|
||||||
public HANACloudColumnStoreDialect() {
|
public HANACloudColumnStoreDialect() {
|
||||||
super();
|
super( 400 );
|
||||||
|
|
||||||
registerColumnType( Types.CHAR, "nvarchar(1)" );
|
|
||||||
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
|
|
||||||
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
|
|
||||||
|
|
||||||
// for longer values map to clob/nclob
|
|
||||||
registerColumnType( Types.LONGVARCHAR, "nclob" );
|
|
||||||
registerColumnType( Types.VARCHAR, "nclob" );
|
|
||||||
registerColumnType( Types.CLOB, "nclob" );
|
|
||||||
|
|
||||||
registerHibernateType( Types.CLOB, StandardBasicTypes.MATERIALIZED_NCLOB.getName() );
|
|
||||||
registerHibernateType( Types.NCHAR, StandardBasicTypes.NSTRING.getName() );
|
|
||||||
registerHibernateType( Types.CHAR, StandardBasicTypes.CHARACTER.getName() );
|
|
||||||
registerHibernateType( Types.CHAR, 1, StandardBasicTypes.CHARACTER.getName() );
|
|
||||||
registerHibernateType( Types.CHAR, 5000, StandardBasicTypes.NSTRING.getName() );
|
|
||||||
registerHibernateType( Types.VARCHAR, StandardBasicTypes.NSTRING.getName() );
|
|
||||||
registerHibernateType( Types.LONGVARCHAR, StandardBasicTypes.NTEXT.getName() );
|
|
||||||
|
|
||||||
// register additional keywords
|
|
||||||
registerHanaCloudKeywords();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
|
||||||
|
|
||||||
// full-text search functions
|
|
||||||
queryEngine.getSqmFunctionRegistry().registerNamed( "score", StandardBasicTypes.DOUBLE );
|
|
||||||
queryEngine.getSqmFunctionRegistry().registerNamed( "snippets" );
|
|
||||||
queryEngine.getSqmFunctionRegistry().registerNamed( "highlighted" );
|
|
||||||
// queryEngine.getSqmFunctionRegistry().registerVarArgs( "contains", StandardSpiBasicTypes.BOOLEAN, "contains(", ",", ") /*" );
|
|
||||||
// queryEngine.getSqmFunctionRegistry().registerPattern( "contains_rhs", "*/", StandardSpiBasicTypes.BOOLEAN );
|
|
||||||
// queryEngine.getSqmFunctionRegistry().registerVarArgs( "not_contains", StandardSpiBasicTypes.BOOLEAN, "not_contains(", ",", ") /*" );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerHanaCloudKeywords() {
|
|
||||||
registerKeyword( "array" );
|
|
||||||
registerKeyword( "at" );
|
|
||||||
registerKeyword( "authorization" );
|
|
||||||
registerKeyword( "between" );
|
|
||||||
registerKeyword( "by" );
|
|
||||||
registerKeyword( "collate" );
|
|
||||||
registerKeyword( "empty" );
|
|
||||||
registerKeyword( "filter" );
|
|
||||||
registerKeyword( "grouping" );
|
|
||||||
registerKeyword( "no" );
|
|
||||||
registerKeyword( "not" );
|
|
||||||
registerKeyword( "of" );
|
|
||||||
registerKeyword( "over" );
|
|
||||||
registerKeyword( "recursive" );
|
|
||||||
registerKeyword( "row" );
|
|
||||||
registerKeyword( "table" );
|
|
||||||
registerKeyword( "to" );
|
|
||||||
registerKeyword( "window" );
|
|
||||||
registerKeyword( "within" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCreateTableString() {
|
|
||||||
return "create column table";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean supportsAsciiStringTypes() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Boolean useUnicodeStringTypesDefault() {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUseUnicodeStringTypes() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,6 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
public class HANAColumnStoreDialect extends AbstractHANADialect {
|
public class HANAColumnStoreDialect extends AbstractHANADialect {
|
||||||
private int version;
|
private int version;
|
||||||
|
|
||||||
public int getVersion(){
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HANAColumnStoreDialect(DialectResolutionInfo info) {
|
public HANAColumnStoreDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
}
|
}
|
||||||
|
@ -74,6 +70,11 @@ public class HANAColumnStoreDialect extends AbstractHANADialect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion(){
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
private void registerHanaCloudKeywords() {
|
private void registerHanaCloudKeywords() {
|
||||||
registerKeyword( "array" );
|
registerKeyword( "array" );
|
||||||
registerKeyword( "at" );
|
registerKeyword( "at" );
|
||||||
|
|
|
@ -56,6 +56,11 @@ public class HANARowStoreDialect extends AbstractHANADialect {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportsAsciiStringTypes() {
|
protected boolean supportsAsciiStringTypes() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -78,10 +78,6 @@ public class HSQLDialect extends Dialect {
|
||||||
*/
|
*/
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HSQLDialect(DialectResolutionInfo info) {
|
public HSQLDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion()*100 + info.getDatabaseMinorVersion()*10 );
|
this( info.getDatabaseMajorVersion()*100 + info.getDatabaseMinorVersion()*10 );
|
||||||
}
|
}
|
||||||
|
@ -143,6 +139,11 @@ public class HSQLDialect extends Dialect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -48,10 +48,6 @@ public class InformixDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InformixDialect(DialectResolutionInfo info) {
|
public InformixDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.getDatabaseMajorVersion() );
|
||||||
}
|
}
|
||||||
|
@ -105,6 +101,12 @@ public class InformixDialect extends Dialect {
|
||||||
: new SkipFirstLimitHandler( getVersion() >= 11 );
|
: new SkipFirstLimitHandler( getVersion() >= 11 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public int getDefaultDecimalPrecision() {
|
||||||
//the maximum
|
//the maximum
|
||||||
return 32;
|
return 32;
|
||||||
|
|
|
@ -64,10 +64,6 @@ public class IngresDialect extends Dialect {
|
||||||
|
|
||||||
private final SequenceSupport sequenceSupport;
|
private final SequenceSupport sequenceSupport;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IngresDialect(DialectResolutionInfo info) {
|
public IngresDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
}
|
}
|
||||||
|
@ -151,6 +147,11 @@ public class IngresDialect extends Dialect {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return getVersion() < 1000 ? Types.BIT : Types.BOOLEAN;
|
return getVersion() < 1000 ? Types.BIT : Types.BOOLEAN;
|
||||||
|
|
|
@ -55,6 +55,11 @@ public class MaxDBDialect extends Dialect {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -85,6 +85,11 @@ public class MimerSQLDialect extends Dialect {
|
||||||
// return 45;
|
// return 45;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -59,10 +59,6 @@ public class MySQLDialect extends Dialect {
|
||||||
private MySQLStorageEngine storageEngine;
|
private MySQLStorageEngine storageEngine;
|
||||||
private int version;
|
private int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MySQLDialect(DialectResolutionInfo info) {
|
public MySQLDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
}
|
}
|
||||||
|
@ -159,6 +155,11 @@ public class MySQLDialect extends Dialect {
|
||||||
uniqueDelegate = new MySQLUniqueDelegate( this );
|
uniqueDelegate = new MySQLUniqueDelegate( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDefaultLobLength() {
|
public long getDefaultLobLength() {
|
||||||
//max length for mediumblob or mediumtext
|
//max length for mediumblob or mediumtext
|
||||||
|
|
|
@ -68,10 +68,6 @@ public class OracleDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OracleDialect(DialectResolutionInfo info) {
|
public OracleDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.getDatabaseMajorVersion() );
|
||||||
}
|
}
|
||||||
|
@ -112,6 +108,11 @@ public class OracleDialect extends Dialect {
|
||||||
: OffsetFetchLimitHandler.INSTANCE;
|
: OffsetFetchLimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -73,10 +73,6 @@ public class PostgreSQLDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PostgreSQLDialect(DialectResolutionInfo info) {
|
public PostgreSQLDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
}
|
}
|
||||||
|
@ -117,6 +113,11 @@ public class PostgreSQLDialect extends Dialect {
|
||||||
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
|
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code extract()} function returns {@link TemporalUnit#DAY_OF_WEEK}
|
* The {@code extract()} function returns {@link TemporalUnit#DAY_OF_WEEK}
|
||||||
* numbered from 0 to 6. This isn't consistent with what most other
|
* numbered from 0 to 6. This isn't consistent with what most other
|
||||||
|
|
|
@ -96,6 +96,11 @@ public class RDMSOS2200Dialect extends Dialect {
|
||||||
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)");
|
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -43,10 +43,6 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
|
|
||||||
private final int version;
|
private final int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SQLServerDialect(DialectResolutionInfo info) {
|
public SQLServerDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.getDatabaseMajorVersion() );
|
||||||
}
|
}
|
||||||
|
@ -103,6 +99,11 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
registerKeyword( "key" );
|
registerKeyword( "key" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getDefaultLobLength() {
|
public long getDefaultLobLength() {
|
||||||
// this is essentially the only legal length for
|
// this is essentially the only legal length for
|
||||||
|
|
|
@ -93,6 +93,11 @@ public class SpannerDialect extends Dialect {
|
||||||
registerColumnType( Types.BLOB, "bytes(max)" );
|
registerColumnType( Types.BLOB, "bytes(max)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry( queryEngine );
|
super.initializeFunctionRegistry( queryEngine );
|
||||||
|
|
|
@ -16,6 +16,6 @@ package org.hibernate.dialect;
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class Sybase11Dialect extends SybaseASEDialect {
|
public class Sybase11Dialect extends SybaseASEDialect {
|
||||||
public Sybase11Dialect() {
|
public Sybase11Dialect() {
|
||||||
super();
|
super(1100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,6 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class SybaseASEDialect extends SybaseDialect {
|
public class SybaseASEDialect extends SybaseDialect {
|
||||||
|
|
||||||
private final int version;
|
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SybaseASEDialect(DialectResolutionInfo info) {
|
public SybaseASEDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
}
|
}
|
||||||
|
@ -45,8 +39,7 @@ public class SybaseASEDialect extends SybaseDialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SybaseASEDialect(int version) {
|
public SybaseASEDialect(int version) {
|
||||||
super();
|
super(version);
|
||||||
this.version = version;
|
|
||||||
|
|
||||||
//On Sybase ASE, the 'bit' type cannot be null,
|
//On Sybase ASE, the 'bit' type cannot be null,
|
||||||
//and cannot have indexes (while we don't use
|
//and cannot have indexes (while we don't use
|
||||||
|
@ -55,6 +48,7 @@ public class SybaseASEDialect extends SybaseDialect {
|
||||||
registerColumnType( Types.BOOLEAN, "tinyint" );
|
registerColumnType( Types.BOOLEAN, "tinyint" );
|
||||||
registerColumnType( Types.BIT, 1, "tinyint" );
|
registerColumnType( Types.BIT, 1, "tinyint" );
|
||||||
|
|
||||||
|
|
||||||
if ( getVersion() >= 1500 ) {
|
if ( getVersion() >= 1500 ) {
|
||||||
//bigint was added in version 15
|
//bigint was added in version 15
|
||||||
registerColumnType( Types.BIGINT, "bigint" );
|
registerColumnType( Types.BIGINT, "bigint" );
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport;
|
import org.hibernate.dialect.identity.SybaseAnywhereIdentityColumnSupport;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.TopLimitHandler;
|
import org.hibernate.dialect.pagination.TopLimitHandler;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.type.descriptor.sql.BitTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.BitTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
|
|
||||||
|
@ -23,7 +24,15 @@ import java.sql.Types;
|
||||||
public class SybaseAnywhereDialect extends SybaseDialect {
|
public class SybaseAnywhereDialect extends SybaseDialect {
|
||||||
|
|
||||||
public SybaseAnywhereDialect() {
|
public SybaseAnywhereDialect() {
|
||||||
super();
|
this(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SybaseAnywhereDialect(DialectResolutionInfo info){
|
||||||
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SybaseAnywhereDialect(int version) {
|
||||||
|
super( version );
|
||||||
|
|
||||||
registerColumnType( Types.BIGINT, "bigint" );
|
registerColumnType( Types.BIGINT, "bigint" );
|
||||||
registerColumnType( Types.DATE, "date" );
|
registerColumnType( Types.DATE, "date" );
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.BlobTypeDescriptor;
|
||||||
|
@ -23,16 +24,31 @@ import java.sql.Types;
|
||||||
*/
|
*/
|
||||||
public class SybaseDialect extends AbstractTransactSQLDialect {
|
public class SybaseDialect extends AbstractTransactSQLDialect {
|
||||||
|
|
||||||
|
private final int version;
|
||||||
|
|
||||||
//All Sybase dialects share an IN list size limit.
|
//All Sybase dialects share an IN list size limit.
|
||||||
private static final int PARAM_LIST_SIZE_LIMIT = 250000;
|
private static final int PARAM_LIST_SIZE_LIMIT = 250000;
|
||||||
|
|
||||||
public SybaseDialect(){
|
public SybaseDialect(){
|
||||||
super();
|
this(1100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SybaseDialect(DialectResolutionInfo info){
|
||||||
|
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SybaseDialect(int version) {
|
||||||
|
super();
|
||||||
|
this.version = version;
|
||||||
//Sybase ASE didn't introduce bigint until version 15.0
|
//Sybase ASE didn't introduce bigint until version 15.0
|
||||||
registerColumnType( Types.BIGINT, "numeric(19,0)" );
|
registerColumnType( Types.BIGINT, "numeric(19,0)" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getInExpressionCountLimit() {
|
public int getInExpressionCountLimit() {
|
||||||
return PARAM_LIST_SIZE_LIMIT;
|
return PARAM_LIST_SIZE_LIMIT;
|
||||||
|
|
|
@ -57,10 +57,6 @@ public class TeradataDialect extends Dialect {
|
||||||
|
|
||||||
private int version;
|
private int version;
|
||||||
|
|
||||||
int getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
|
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
|
||||||
|
|
||||||
public TeradataDialect(DialectResolutionInfo info) {
|
public TeradataDialect(DialectResolutionInfo info) {
|
||||||
|
@ -118,6 +114,11 @@ public class TeradataDialect extends Dialect {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -85,6 +85,11 @@ public class TimesTenDialect extends Dialect {
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return Types.BIT;
|
return Types.BIT;
|
||||||
|
|
|
@ -15,22 +15,30 @@ import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||||
*/
|
*/
|
||||||
public class TestingDialects {
|
public class TestingDialects {
|
||||||
|
|
||||||
public static class MyDialect1 extends Dialect {
|
public static class MyDialect extends Dialect {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyDialect21 extends Dialect {
|
public static class MyDialect1 extends MyDialect {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyDialect22 extends Dialect {
|
public static class MyDialect21 extends MyDialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyDialect311 extends Dialect {
|
public static class MyDialect22 extends MyDialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyDialect312 extends Dialect {
|
public static class MyDialect311 extends MyDialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MySpecialDB2Dialect extends Dialect {
|
public static class MyDialect312 extends MyDialect {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MySpecialDB2Dialect extends MyDialect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MyDialectResolver1 implements DialectResolver {
|
public static class MyDialectResolver1 implements DialectResolver {
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.id;
|
|
||||||
|
|
||||||
import org.hibernate.FlushMode;
|
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
|
||||||
|
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
|
|
||||||
@TestForIssue(jiraKey = "HHH-12464")
|
|
||||||
public class CreateDeleteTest extends BaseCoreFunctionalTestCase {
|
|
||||||
@Test
|
|
||||||
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
|
|
||||||
public void createAndDeleteAnEntityInTheSameTransactionTest() {
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
|
||||||
session.setHibernateFlushMode( FlushMode.COMMIT );
|
|
||||||
RootEntity entity = new RootEntity();
|
|
||||||
session.persist( entity );
|
|
||||||
session.delete( entity );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class[] getAnnotatedClasses() {
|
|
||||||
return new Class[] {
|
|
||||||
RootEntity.class,
|
|
||||||
RelatedEntity.class,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.hibernate.id;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.Transaction;
|
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
@TestForIssue(jiraKey = "HHH-8611")
|
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
|
|
||||||
public class FlushIdGenTest extends BaseCoreFunctionalTestCase {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@SkipForDialect(value = AbstractHANADialect.class, comment = " HANA doesn't support tables consisting of only a single auto-generated column")
|
|
||||||
public void testPersistBeforeTransaction() {
|
|
||||||
Session session = openSession();
|
|
||||||
RootEntity ent1_0 = new RootEntity();
|
|
||||||
RootEntity ent1_1 = new RootEntity();
|
|
||||||
|
|
||||||
session.persist( ent1_0 );
|
|
||||||
session.persist( ent1_1 );
|
|
||||||
|
|
||||||
Transaction tx = session.beginTransaction();
|
|
||||||
tx.commit(); // flush
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class[] getAnnotatedClasses() {
|
|
||||||
return new Class[]{
|
|
||||||
RootEntity.class,
|
|
||||||
RelatedEntity.class,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.id;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.dialect.Oracle12cDialect;
|
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Vlad Mihalcea
|
|
||||||
*/
|
|
||||||
@RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class, jiraKey = "HHH-9271")
|
|
||||||
@SkipForDialect(value = Oracle12cDialect.class, comment = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
|
|
||||||
public class QuotedIdentifierTest extends BaseCoreFunctionalTestCase {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDirectIdPropertyAccess() {
|
|
||||||
QuotedIdentifier quotedIdentifier = new QuotedIdentifier();
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
|
||||||
quotedIdentifier.timestamp = System.currentTimeMillis();
|
|
||||||
quotedIdentifier.from = "HHH-9271";
|
|
||||||
session.persist( quotedIdentifier );
|
|
||||||
} );
|
|
||||||
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
|
||||||
QuotedIdentifier result = session.get( QuotedIdentifier.class, quotedIdentifier.index );
|
|
||||||
assertNotNull( result );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
|
||||||
return new Class<?>[] {
|
|
||||||
QuotedIdentifier.class
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity(name = "QuotedIdentifier")
|
|
||||||
@Table( name = "`table`")
|
|
||||||
public static class QuotedIdentifier {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "`index`")
|
|
||||||
private int index;
|
|
||||||
|
|
||||||
@Column(name = "`timestamp`")
|
|
||||||
private long timestamp;
|
|
||||||
|
|
||||||
@Column(name = "`from`")
|
|
||||||
private String from;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
@ServiceRegistry(settings = @ServiceRegistry.Setting(name = Environment.AUTO_CLOSE_SESSION, value = "true"))
|
@ServiceRegistry(settings = @ServiceRegistry.Setting(name = Environment.AUTO_CLOSE_SESSION, value = "true"))
|
||||||
public class GenericsTest {
|
public class GenericsTest {
|
||||||
|
|
||||||
@SkipForDialect(dialectClass = AbstractHANADialect.class, reason = "known bug in HANA: rs.next() returns false for org.hibernate.id.enhanced.SequenceStructure$1.getNextValue() for this test")
|
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = "known bug in HANA: rs.next() returns false for org.hibernate.id.enhanced.SequenceStructure$1.getNextValue() for this test")
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOneGenerics(SessionFactoryScope scope) {
|
public void testManyToOneGenerics(SessionFactoryScope scope) {
|
||||||
Paper white = new Paper();
|
Paper white = new Paper();
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class EntityInheritanceAttributeOverrideTest extends EntityManagerFactory
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "AbstractEntity")
|
@Entity(name = "AbstractEntity")
|
||||||
|
|
|
@ -484,10 +484,18 @@ public class PersistenceUnitOverridesTests extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PersistenceUnitDialect extends Dialect {
|
public static class PersistenceUnitDialect extends Dialect {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public static class IntegrationDialect extends Dialect {
|
public static class IntegrationDialect extends Dialect {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -4,21 +4,23 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.hibernate.id.IdentifierGenerationException;
|
||||||
|
import org.hibernate.id.IntegralDataTypeHolder;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
public abstract class AbstractHolderTest extends BaseUnitTestCase {
|
public abstract class AbstractHolderTest extends BaseUnitTest {
|
||||||
protected abstract IntegralDataTypeHolder makeHolder();
|
protected abstract IntegralDataTypeHolder makeHolder();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -126,6 +128,7 @@ public abstract class AbstractHolderTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
assertEquals( holder.copy().initialize( i ), holder );
|
assertEquals( holder.copy().initialize( i ), holder );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicHiloAlgorithm() {
|
public void testBasicHiloAlgorithm() {
|
||||||
// mimic an initialValue of 1 and increment of 20
|
// mimic an initialValue of 1 and increment of 20
|
|
@ -4,9 +4,13 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||||
|
import org.hibernate.id.IntegralDataTypeHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -4,9 +4,13 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||||
|
import org.hibernate.id.IntegralDataTypeHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.id;
|
||||||
|
|
||||||
|
import org.hibernate.FlushMode;
|
||||||
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsIdentityColumns.class)
|
||||||
|
@TestForIssue(jiraKey = "HHH-12464")
|
||||||
|
@DomainModel(
|
||||||
|
annotatedClasses = {
|
||||||
|
RootEntity.class,
|
||||||
|
RelatedEntity.class,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class CreateDeleteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = " HANA doesn't support tables consisting of only a single auto-generated column")
|
||||||
|
public void createAndDeleteAnEntityInTheSameTransactionTest(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
session.setHibernateFlushMode( FlushMode.COMMIT );
|
||||||
|
RootEntity entity = new RootEntity();
|
||||||
|
session.persist( entity );
|
||||||
|
session.delete( entity );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.id;
|
||||||
|
|
||||||
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportsIdentityColumns;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@TestForIssue(jiraKey = "HHH-8611")
|
||||||
|
@RequiresDialectFeature(feature = SupportsIdentityColumns.class)
|
||||||
|
@DomainModel(
|
||||||
|
annotatedClasses = {
|
||||||
|
RootEntity.class,
|
||||||
|
RelatedEntity.class,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class FlushIdGenTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = " HANA doesn't support tables consisting of only a single auto-generated column")
|
||||||
|
public void testPersistBeforeTransaction(SessionFactoryScope scope) {
|
||||||
|
scope.inSession(
|
||||||
|
session -> {
|
||||||
|
RootEntity ent1_0 = new RootEntity();
|
||||||
|
RootEntity ent1_1 = new RootEntity();
|
||||||
|
|
||||||
|
session.persist( ent1_0 );
|
||||||
|
session.persist( ent1_1 );
|
||||||
|
|
||||||
|
Transaction tx = session.beginTransaction();
|
||||||
|
try {
|
||||||
|
tx.commit(); // flush
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
tx.rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,9 +4,12 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
|
|
||||||
|
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||||
|
import org.hibernate.id.IntegralDataTypeHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.id;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.OracleDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportsIdentityColumns;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Vlad Mihalcea
|
||||||
|
*/
|
||||||
|
@RequiresDialectFeature(feature = SupportsIdentityColumns.class, jiraKey = "HHH-9271")
|
||||||
|
@SkipForDialect(dialectClass = OracleDialect.class, version = 12, matchSubTypes = true, reason = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
|
||||||
|
@DomainModel(
|
||||||
|
annotatedClasses = {
|
||||||
|
QuotedIdentifierTest.QuotedIdentifier.class
|
||||||
|
}
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class QuotedIdentifierTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDirectIdPropertyAccess(SessionFactoryScope scope) {
|
||||||
|
QuotedIdentifier quotedIdentifier = new QuotedIdentifier();
|
||||||
|
scope.inTransaction( session -> {
|
||||||
|
quotedIdentifier.timestamp = System.currentTimeMillis();
|
||||||
|
quotedIdentifier.from = "HHH-9271";
|
||||||
|
session.persist( quotedIdentifier );
|
||||||
|
} );
|
||||||
|
|
||||||
|
scope.inTransaction( session -> {
|
||||||
|
QuotedIdentifier result = session.get( QuotedIdentifier.class, quotedIdentifier.index );
|
||||||
|
assertNotNull( result );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity(name = "QuotedIdentifier")
|
||||||
|
@Table(name = "`table`")
|
||||||
|
public static class QuotedIdentifier {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@Column(name = "`index`")
|
||||||
|
private int index;
|
||||||
|
|
||||||
|
@Column(name = "`timestamp`")
|
||||||
|
private long timestamp;
|
||||||
|
|
||||||
|
@Column(name = "`from`")
|
||||||
|
private String from;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
|
@ -5,7 +5,7 @@
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -4,34 +4,35 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
|
|
||||||
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.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
|
import org.hibernate.id.SequenceGenerator;
|
||||||
|
import org.hibernate.id.SequenceHiLoGenerator;
|
||||||
import org.hibernate.internal.SessionImpl;
|
import org.hibernate.internal.SessionImpl;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportsSequences;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
||||||
|
@ -40,8 +41,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"deprecation"})
|
@SuppressWarnings({"deprecation"})
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = SupportsSequences.class)
|
||||||
public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
|
public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTest {
|
||||||
private static final String TEST_SEQUENCE = "test_sequence";
|
private static final String TEST_SEQUENCE = "test_sequence";
|
||||||
|
|
||||||
private StandardServiceRegistry serviceRegistry;
|
private StandardServiceRegistry serviceRegistry;
|
||||||
|
@ -50,7 +51,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
|
||||||
private SessionImplementor sessionImpl;
|
private SessionImplementor sessionImpl;
|
||||||
private SequenceValueExtractor sequenceValueExtractor;
|
private SequenceValueExtractor sequenceValueExtractor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder()
|
serviceRegistry = new StandardServiceRegistryBuilder()
|
||||||
.enableAutoClose()
|
.enableAutoClose()
|
||||||
|
@ -79,7 +80,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends BaseUnitTestCase {
|
||||||
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
if ( sessionImpl != null && !sessionImpl.isClosed() ) {
|
if ( sessionImpl != null && !sessionImpl.isClosed() ) {
|
||||||
sessionImpl.close();
|
sessionImpl.close();
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -17,18 +17,22 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
|
import org.hibernate.id.SequenceGenerator;
|
||||||
|
import org.hibernate.id.SequenceHiLoGenerator;
|
||||||
import org.hibernate.internal.SessionImpl;
|
import org.hibernate.internal.SessionImpl;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.After;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
import org.junit.Before;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportsSequences;
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
||||||
|
@ -37,8 +41,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"deprecation"})
|
@SuppressWarnings({"deprecation"})
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = SupportsSequences.class)
|
||||||
public class SequenceHiLoGeneratorTest extends BaseUnitTestCase {
|
public class SequenceHiLoGeneratorTest extends BaseUnitTest {
|
||||||
private static final String TEST_SEQUENCE = "test_sequence";
|
private static final String TEST_SEQUENCE = "test_sequence";
|
||||||
|
|
||||||
private StandardServiceRegistry serviceRegistry;
|
private StandardServiceRegistry serviceRegistry;
|
||||||
|
@ -47,7 +51,7 @@ public class SequenceHiLoGeneratorTest extends BaseUnitTestCase {
|
||||||
private SessionImplementor sessionImpl;
|
private SessionImplementor sessionImpl;
|
||||||
private SequenceValueExtractor sequenceValueExtractor;
|
private SequenceValueExtractor sequenceValueExtractor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder()
|
serviceRegistry = new StandardServiceRegistryBuilder()
|
||||||
.enableAutoClose()
|
.enableAutoClose()
|
||||||
|
@ -74,8 +78,8 @@ public class SequenceHiLoGeneratorTest extends BaseUnitTestCase {
|
||||||
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() {
|
||||||
if ( sessionFactory != null ) {
|
if ( sessionFactory != null ) {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -18,25 +18,26 @@ import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||||
import org.hibernate.internal.SessionImpl;
|
import org.hibernate.internal.SessionImpl;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.After;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks.SupportsSequences;
|
||||||
import org.junit.Before;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = SupportsSequences.class)
|
||||||
public class SequenceStyleGeneratorBehavesLikeSequeceHiloGeneratorWitZeroIncrementSizeTest extends BaseUnitTestCase {
|
public class SequenceStyleGeneratorBehavesLikeSequeceHiloGeneratorWitZeroIncrementSizeTest extends BaseUnitTest {
|
||||||
private static final String TEST_SEQUENCE = "test_sequence";
|
private static final String TEST_SEQUENCE = "test_sequence";
|
||||||
|
|
||||||
private StandardServiceRegistry serviceRegistry;
|
private StandardServiceRegistry serviceRegistry;
|
||||||
|
@ -45,7 +46,7 @@ public class SequenceStyleGeneratorBehavesLikeSequeceHiloGeneratorWitZeroIncreme
|
||||||
private SessionImplementor sessionImpl;
|
private SessionImplementor sessionImpl;
|
||||||
private SequenceValueExtractor sequenceValueExtractor;
|
private SequenceValueExtractor sequenceValueExtractor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder()
|
serviceRegistry = new StandardServiceRegistryBuilder()
|
||||||
.enableAutoClose()
|
.enableAutoClose()
|
||||||
|
@ -77,7 +78,7 @@ public class SequenceStyleGeneratorBehavesLikeSequeceHiloGeneratorWitZeroIncreme
|
||||||
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
if ( sessionImpl != null && !sessionImpl.isClosed() ) {
|
if ( sessionImpl != null && !sessionImpl.isClosed() ) {
|
||||||
sessionImpl.close();
|
sessionImpl.close();
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.orm.test.id;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
|
@ -4,23 +4,26 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.enhanced;
|
package org.hibernate.orm.test.id.enhanced;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||||
import org.hibernate.id.IntegralDataTypeHolder;
|
import org.hibernate.id.IntegralDataTypeHolder;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.id.enhanced.AccessCallback;
|
||||||
|
import org.hibernate.id.enhanced.Optimizer;
|
||||||
|
import org.hibernate.id.enhanced.OptimizerFactory;
|
||||||
|
import org.hibernate.id.enhanced.StandardOptimizerDescriptor;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class OptimizerUnitTest extends BaseUnitTestCase {
|
public class OptimizerUnitTest extends BaseUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicNoOptimizerUsage() {
|
public void testBasicNoOptimizerUsage() {
|
||||||
// test historic sequence behavior, where the initial values start at 1...
|
// test historic sequence behavior, where the initial values start at 1...
|
||||||
|
@ -44,6 +47,7 @@ public class OptimizerUnitTest extends BaseUnitTestCase {
|
||||||
assertEquals( 10, sequence.getTimesCalled() ); // an extra time to get to 1 initially
|
assertEquals( 10, sequence.getTimesCalled() ); // an extra time to get to 1 initially
|
||||||
assertEquals( 9, sequence.getCurrentValue() );
|
assertEquals( 9, sequence.getCurrentValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicNoOptimizerUsageWithNegativeValues() {
|
public void testBasicNoOptimizerUsageWithNegativeValues() {
|
||||||
// test historic sequence behavior, where the initial values start at 1...
|
// test historic sequence behavior, where the initial values start at 1...
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.enhanced;
|
package org.hibernate.orm.test.id.enhanced;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -17,21 +17,30 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.id.PersistentIdentifierGenerator;
|
import org.hibernate.id.PersistentIdentifierGenerator;
|
||||||
|
import org.hibernate.id.enhanced.HiLoOptimizer;
|
||||||
|
import org.hibernate.id.enhanced.NoopOptimizer;
|
||||||
|
import org.hibernate.id.enhanced.PooledLoOptimizer;
|
||||||
|
import org.hibernate.id.enhanced.PooledLoThreadLocalOptimizer;
|
||||||
|
import org.hibernate.id.enhanced.PooledOptimizer;
|
||||||
|
import org.hibernate.id.enhanced.SequenceStructure;
|
||||||
|
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||||
|
import org.hibernate.id.enhanced.StandardOptimizerDescriptor;
|
||||||
|
import org.hibernate.id.enhanced.TableStructure;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertClassAssignability;
|
import static org.hibernate.testing.junit5.ExtraAssertions.assertClassAssignability;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that SequenceStyleGenerator configures itself as expected in various scenarios
|
* Tests that SequenceStyleGenerator configures itself as expected in various scenarios
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
public class SequenceStyleConfigUnitTest extends BaseUnitTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test all params defaulted with a dialect supporting sequences
|
* Test all params defaulted with a dialect supporting sequences
|
||||||
|
@ -310,18 +319,31 @@ public class SequenceStyleConfigUnitTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TableDialect extends Dialect {
|
public static class TableDialect extends Dialect {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
public boolean supportsSequences() {
|
public boolean supportsSequences() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SequenceDialect extends Dialect {
|
public static class SequenceDialect extends Dialect {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean supportsSequences() {
|
public boolean supportsSequences() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean supportsPooledSequences() {
|
public boolean supportsPooledSequences() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getSequenceNextValString(String sequenceName) throws MappingException {
|
public String getSequenceNextValString(String sequenceName) throws MappingException {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
|
@ -4,13 +4,14 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -22,32 +23,32 @@ 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.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
import org.hibernate.dialect.PostgreSQLDialect;
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
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.testing.RequiresDialect;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit5.EntityManagerFactoryBasedFunctionalTest;
|
||||||
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.hibernate.testing.orm.junit.RequiresDialect;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
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.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
@RequiresDialect(value = PostgreSQLDialect.class, version = 820)
|
||||||
public class PostgreSQLSequenceGeneratorWithSerialTest extends BaseEntityManagerFunctionalTestCase {
|
public class PostgreSQLSequenceGeneratorWithSerialTest extends EntityManagerFactoryBasedFunctionalTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public LoggerInspectionRule logInspection = new LoggerInspectionRule( Logger.getMessageLogger( CoreMessageLogger.class,
|
public LoggerInspectionRule logInspection = new LoggerInspectionRule( Logger.getMessageLogger( CoreMessageLogger.class,
|
||||||
|
@ -69,7 +70,7 @@ public class PostgreSQLSequenceGeneratorWithSerialTest extends BaseEntityManager
|
||||||
private static final String CREATE_TABLE = "CREATE TABLE application_configurations (id BIGSERIAL NOT NULL PRIMARY KEY)";
|
private static final String CREATE_TABLE = "CREATE TABLE application_configurations (id BIGSERIAL NOT NULL PRIMARY KEY)";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map settings) {
|
||||||
triggerable.reset();
|
triggerable.reset();
|
||||||
assertFalse( triggerable.wasTriggered() );
|
assertFalse( triggerable.wasTriggered() );
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ public class PostgreSQLSequenceGeneratorWithSerialTest extends BaseEntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterEntityManagerFactoryBuilt() {
|
protected void entityManagerFactoryBuilt(EntityManagerFactory factory) {
|
||||||
assertTrue( triggerable.wasTriggered() );
|
assertTrue( triggerable.wasTriggered() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -20,42 +20,33 @@ 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.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.logger.LoggerInspectionRule;
|
import org.hibernate.testing.junit5.EntityManagerFactoryBasedFunctionalTest;
|
||||||
import org.hibernate.testing.logger.Triggerable;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
public class SequenceMismatchStrategyDefaultExceptionTest extends BaseEntityManagerFunctionalTestCase {
|
public class SequenceMismatchStrategyDefaultExceptionTest extends EntityManagerFactoryBasedFunctionalTest {
|
||||||
|
|
||||||
protected ServiceRegistry serviceRegistry;
|
protected ServiceRegistry serviceRegistry;
|
||||||
protected MetadataImplementor metadata;
|
protected MetadataImplementor metadata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildEntityManagerFactory() {
|
public EntityManagerFactory produceEntityManagerFactory() {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
||||||
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
||||||
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
||||||
|
@ -63,7 +54,7 @@ public class SequenceMismatchStrategyDefaultExceptionTest extends BaseEntityMana
|
||||||
|
|
||||||
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
try {
|
try {
|
||||||
super.buildEntityManagerFactory();
|
super.produceEntityManagerFactory();
|
||||||
|
|
||||||
fail("Should throw MappingException!");
|
fail("Should throw MappingException!");
|
||||||
}
|
}
|
||||||
|
@ -71,16 +62,11 @@ public class SequenceMismatchStrategyDefaultExceptionTest extends BaseEntityMana
|
||||||
Throwable rootCause = ExceptionUtil.rootCause( e );
|
Throwable rootCause = ExceptionUtil.rootCause( e );
|
||||||
assertTrue( rootCause instanceof MappingException );
|
assertTrue( rootCause instanceof MappingException );
|
||||||
assertTrue( rootCause.getMessage().contains( "in the entity mapping while the associated database sequence increment size is" ) );
|
assertTrue( rootCause.getMessage().contains( "in the entity mapping while the associated database sequence increment size is" ) );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void releaseResources() {
|
|
||||||
super.releaseResources();
|
|
||||||
|
|
||||||
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
@ -90,13 +76,13 @@ public class SequenceMismatchStrategyDefaultExceptionTest extends BaseEntityMana
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map options) {
|
||||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
options.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
|
@ -4,28 +4,28 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
import org.hibernate.id.SequenceMismatchStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
public class SequenceMismatchStrategyExceptionEnumTest extends SequenceMismatchStrategyDefaultExceptionTest {
|
public class SequenceMismatchStrategyExceptionEnumTest extends SequenceMismatchStrategyDefaultExceptionTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map options) {
|
||||||
super.addMappings( settings );
|
super.addConfigOptions( options );
|
||||||
settings.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, SequenceMismatchStrategy.EXCEPTION );
|
options.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, SequenceMismatchStrategy.EXCEPTION );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,12 +4,13 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -19,41 +20,34 @@ 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.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
|
||||||
import org.hibernate.dialect.H2Dialect;
|
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
|
||||||
import org.hibernate.dialect.SQLServer2012Dialect;
|
|
||||||
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.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit5.EntityManagerFactoryBasedFunctionalTest;
|
||||||
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.hibernate.test.schemaupdate.SchemaExportWithGlobalQuotingEnabledTest;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends BaseEntityManagerFunctionalTestCase {
|
public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends EntityManagerFactoryBasedFunctionalTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
||||||
|
@ -69,20 +63,18 @@ public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends BaseEn
|
||||||
protected MetadataImplementor metadata;
|
protected MetadataImplementor metadata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildEntityManagerFactory() {
|
public EntityManagerFactory produceEntityManagerFactory() {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
||||||
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
||||||
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
||||||
.buildMetadata();
|
.buildMetadata();
|
||||||
|
|
||||||
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
super.buildEntityManagerFactory();
|
return super.produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterAll
|
||||||
public void releaseResources() {
|
public void releaseResources() {
|
||||||
super.releaseResources();
|
|
||||||
|
|
||||||
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
@ -95,14 +87,14 @@ public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends BaseEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map options) {
|
||||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
options.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
||||||
settings.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, "fix" );
|
options.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, "fix" );
|
||||||
triggerable.reset();
|
triggerable.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterEntityManagerFactoryBuilt() {
|
protected void entityManagerFactoryBuilt(EntityManagerFactory factory) {
|
||||||
assertTrue( triggerable.wasTriggered() );
|
assertTrue( triggerable.wasTriggered() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +105,7 @@ public class SequenceMismatchStrategyFixWithSequenceGeneratorTest extends BaseEn
|
||||||
|
|
||||||
final int ITERATIONS = 51;
|
final int ITERATIONS = 51;
|
||||||
|
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
inTransaction( entityManager -> {
|
||||||
for ( int i = 1; i <= ITERATIONS; i++ ) {
|
for ( int i = 1; i <= ITERATIONS; i++ ) {
|
||||||
ApplicationConfiguration model = new ApplicationConfiguration();
|
ApplicationConfiguration model = new ApplicationConfiguration();
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -20,30 +21,31 @@ import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
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.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit5.EntityManagerFactoryBasedFunctionalTest;
|
||||||
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.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
public class SequenceMismatchStrategyLogTest extends BaseEntityManagerFunctionalTestCase {
|
public class SequenceMismatchStrategyLogTest extends EntityManagerFactoryBasedFunctionalTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
||||||
|
@ -59,20 +61,18 @@ public class SequenceMismatchStrategyLogTest extends BaseEntityManagerFunctional
|
||||||
protected MetadataImplementor metadata;
|
protected MetadataImplementor metadata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildEntityManagerFactory() {
|
public EntityManagerFactory produceEntityManagerFactory() {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
||||||
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
||||||
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
||||||
.buildMetadata();
|
.buildMetadata();
|
||||||
|
|
||||||
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
super.buildEntityManagerFactory();
|
return super.produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterAll
|
||||||
public void releaseResources() {
|
public void releaseResources() {
|
||||||
super.releaseResources();
|
|
||||||
|
|
||||||
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
@ -85,20 +85,21 @@ public class SequenceMismatchStrategyLogTest extends BaseEntityManagerFunctional
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map options) {
|
||||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
options.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
||||||
settings.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, "log" );
|
options.put( AvailableSettings.SEQUENCE_INCREMENT_SIZE_MISMATCH_STRATEGY, "log" );
|
||||||
triggerable.reset();
|
triggerable.reset();
|
||||||
assertFalse( triggerable.wasTriggered() );
|
assertFalse( triggerable.wasTriggered() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterEntityManagerFactoryBuilt() {
|
protected void entityManagerFactoryBuilt(EntityManagerFactory factory) {
|
||||||
assertTrue( triggerable.wasTriggered() );
|
assertTrue( triggerable.wasTriggered() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
|
@ -4,23 +4,21 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
import org.hibernate.id.SequenceMismatchStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
public class SequenceMismatchStrategyLowerCaseStringValueTest extends BaseUnitTestCase {
|
public class SequenceMismatchStrategyLowerCaseStringValueTest extends BaseUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
|
@ -4,21 +4,22 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
import org.hibernate.id.SequenceMismatchStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
public class SequenceMismatchStrategyNullValueTest extends BaseUnitTestCase {
|
public class SequenceMismatchStrategyNullValueTest extends BaseUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
|
@ -4,25 +4,25 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
import org.hibernate.id.SequenceMismatchStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.hibernate.testing.util.ExceptionUtil;
|
import org.hibernate.testing.util.ExceptionUtil;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
public class SequenceMismatchStrategyUnknownEnumValueTest extends BaseUnitTestCase {
|
public class SequenceMismatchStrategyUnknownEnumValueTest extends BaseUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
|
@ -4,21 +4,21 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import org.hibernate.id.SequenceMismatchStrategy;
|
import org.hibernate.id.SequenceMismatchStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
public class SequenceMismatchStrategyUpperCaseStringValueTest extends BaseUnitTestCase {
|
public class SequenceMismatchStrategyUpperCaseStringValueTest extends BaseUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
|
@ -4,12 +4,13 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.hhh12973;
|
package org.hibernate.orm.test.id.hhh12973;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
@ -21,32 +22,31 @@ import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
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.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit5.EntityManagerFactoryBasedFunctionalTest;
|
||||||
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.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends BaseEntityManagerFunctionalTestCase {
|
public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends EntityManagerFactoryBasedFunctionalTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
public LoggerInspectionRule logInspection = new LoggerInspectionRule(
|
||||||
|
@ -62,20 +62,18 @@ public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends BaseEn
|
||||||
protected MetadataImplementor metadata;
|
protected MetadataImplementor metadata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buildEntityManagerFactory() {
|
public EntityManagerFactory produceEntityManagerFactory() {
|
||||||
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
serviceRegistry = new StandardServiceRegistryBuilder().build();
|
||||||
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
|
||||||
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
.addAnnotatedClass( ApplicationConfigurationHBM2DDL.class )
|
||||||
.buildMetadata();
|
.buildMetadata();
|
||||||
|
|
||||||
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
super.buildEntityManagerFactory();
|
return super.produceEntityManagerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterAll
|
||||||
public void releaseResources() {
|
public void releaseResources() {
|
||||||
super.releaseResources();
|
|
||||||
|
|
||||||
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), metadata );
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
@ -88,13 +86,13 @@ public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends BaseEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addMappings(Map settings) {
|
protected void addConfigOptions(Map options) {
|
||||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
options.put( AvailableSettings.HBM2DDL_AUTO, "none" );
|
||||||
triggerable.reset();
|
triggerable.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterEntityManagerFactoryBuilt() {
|
protected void entityManagerFactoryBuilt(EntityManagerFactory factory) {
|
||||||
assertFalse( triggerable.wasTriggered() );
|
assertFalse( triggerable.wasTriggered() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +103,7 @@ public class SequenceMismatchStrategyWithoutSequenceGeneratorTest extends BaseEn
|
||||||
|
|
||||||
final int ITERATIONS = 51;
|
final int ITERATIONS = 51;
|
||||||
|
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
inTransaction( entityManager -> {
|
||||||
for ( int i = 1; i <= ITERATIONS; i++ ) {
|
for ( int i = 1; i <= ITERATIONS; i++ ) {
|
||||||
ApplicationConfiguration model = new ApplicationConfiguration();
|
ApplicationConfiguration model = new ApplicationConfiguration();
|
||||||
|
|
|
@ -4,20 +4,24 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.uuid;
|
package org.hibernate.orm.test.id.uuid;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.id.uuid.CustomVersionOneStrategy;
|
||||||
import org.junit.Test;
|
|
||||||
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class CustomVersionOneStrategyTest extends BaseUnitTestCase {
|
public class CustomVersionOneStrategyTest extends BaseUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUniqueCounter() {
|
public void testUniqueCounter() {
|
||||||
CustomVersionOneStrategy strategy = new CustomVersionOneStrategy();
|
CustomVersionOneStrategy strategy = new CustomVersionOneStrategy();
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id.uuid;
|
package org.hibernate.orm.test.id.uuid;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
|
@ -26,19 +26,19 @@ import org.hibernate.id.UUIDGenerator;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.RootClass;
|
import org.hibernate.mapping.RootClass;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit5.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
import static org.hibernate.testing.junit5.ExtraAssertions.assertTyping;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests a UUID attribute annotated as a generated id value.
|
* Tests a UUID attribute annotated as a generated id value.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class GeneratedValueTest extends BaseUnitTestCase {
|
public class GeneratedValueTest extends BaseUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGeneratedUuidId() throws Exception {
|
public void testGeneratedUuidId() throws Exception {
|
||||||
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
|
@ -66,6 +66,7 @@ public class GeneratedValueTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
try {
|
||||||
s.save( theEntity );
|
s.save( theEntity );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
@ -74,7 +75,7 @@ public class GeneratedValueTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
s = sf.openSession();
|
s = sf.openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
try {
|
|
||||||
s.delete( theEntity );
|
s.delete( theEntity );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
}
|
}
|
|
@ -22,9 +22,7 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* @author Pawel Stawicki
|
* @author Pawel Stawicki
|
||||||
*/
|
*/
|
||||||
@RequiresDialects(value = {
|
@RequiresDialect(value = PostgreSQLDialect.class, version = 800)
|
||||||
@RequiresDialect(value = PostgreSQL81Dialect.class), @RequiresDialect(value = PostgreSQLDialect.class)
|
|
||||||
})
|
|
||||||
@DomainModel(annotatedClasses = {
|
@DomainModel(annotatedClasses = {
|
||||||
ParentEntity.class, InheritingEntity.class
|
ParentEntity.class, InheritingEntity.class
|
||||||
})
|
})
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class CriteriaLiteralWithSingleQuoteTest extends EntityManagerFactoryBase
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(dialectClass = PostgreSQLDialect.class, reason = "PostgreSQL does not support literals in group by statement")
|
@SkipForDialect(dialectClass = PostgreSQLDialect.class, matchSubTypes = true, reason = "PostgreSQL does not support literals in group by statement")
|
||||||
public void testLiteralProjectionAndGroupBy() {
|
public void testLiteralProjectionAndGroupBy() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.RowId;
|
import org.hibernate.annotations.RowId;
|
||||||
import org.hibernate.dialect.Oracle9iDialect;
|
import org.hibernate.dialect.OracleDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.jdbc.SQLStatementInspector;
|
import org.hibernate.testing.jdbc.SQLStatementInspector;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
@ -33,7 +33,7 @@ import static org.junit.Assert.assertThat;
|
||||||
*/
|
*/
|
||||||
@DomainModel( annotatedClasses = RowIdTest.Product.class )
|
@DomainModel( annotatedClasses = RowIdTest.Product.class )
|
||||||
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
|
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
|
||||||
@RequiresDialect( value = Oracle9iDialect.class )
|
@RequiresDialect( value = OracleDialect.class, version = 9)
|
||||||
public class RowIdTest {
|
public class RowIdTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
|
|
@ -89,6 +89,11 @@ public class QualifiedTableNamingTest extends BaseNonConfigCoreFunctionalTestCas
|
||||||
public NameQualifierSupport getNameQualifierSupport() {
|
public NameQualifierSupport getNameQualifierSupport() {
|
||||||
return NameQualifierSupport.BOTH;
|
return NameQualifierSupport.BOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MockedConnectionProvider implements ConnectionProvider {
|
public static class MockedConnectionProvider implements ConnectionProvider {
|
||||||
|
|
|
@ -35,6 +35,10 @@ public class DefaultSchemaNameResolverTest {
|
||||||
String schemaName = DefaultSchemaNameResolver.INSTANCE.resolveSchemaName(
|
String schemaName = DefaultSchemaNameResolver.INSTANCE.resolveSchemaName(
|
||||||
connectionSupportsGetSchemaName,
|
connectionSupportsGetSchemaName,
|
||||||
new Dialect() {
|
new Dialect() {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assertEquals( SCHEMA_NAME, schemaName );
|
assertEquals( SCHEMA_NAME, schemaName );
|
||||||
|
@ -44,6 +48,12 @@ public class DefaultSchemaNameResolverTest {
|
||||||
schemaName = DefaultSchemaNameResolver.INSTANCE.resolveSchemaName(
|
schemaName = DefaultSchemaNameResolver.INSTANCE.resolveSchemaName(
|
||||||
connectionNotSupportGetSchemaName,
|
connectionNotSupportGetSchemaName,
|
||||||
new Dialect() {
|
new Dialect() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentSchemaCommand() {
|
public String getCurrentSchemaCommand() {
|
||||||
return GET_CURRENT_SCHEMA_NAME_COMMAND ;
|
return GET_CURRENT_SCHEMA_NAME_COMMAND ;
|
||||||
|
|
|
@ -85,6 +85,11 @@ public class NoDatabaseMetaDataTest extends BaseUnitTestCase {
|
||||||
public boolean supportsNamedParameters(java.sql.DatabaseMetaData databaseMetaData) {
|
public boolean supportsNamedParameters(java.sql.DatabaseMetaData databaseMetaData) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,5 +68,10 @@ public class CommentGenerationTest {
|
||||||
public boolean supportsCommentOn() {
|
public boolean supportsCommentOn() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,10 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
return new Dialect() {
|
return new Dialect() {
|
||||||
|
@Override
|
||||||
|
public int getVersion(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,10 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
return new Dialect() {
|
return new Dialect() {
|
||||||
|
@Override
|
||||||
|
public int getVersion() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,17 +65,19 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
for ( RequiresDialect requiresDialect : effectiveRequiresDialects ) {
|
for ( RequiresDialect requiresDialect : effectiveRequiresDialects ) {
|
||||||
requiredDialects.append( requiresDialect.value() );
|
requiredDialects.append( requiresDialect.value() );
|
||||||
requiredDialects.append( " " );
|
requiredDialects.append( " " );
|
||||||
if ( requiresDialect.matchSubTypes() ) {
|
|
||||||
if ( requiresDialect.value().isInstance( dialect ) ) {
|
if ( requiresDialect.value().isInstance( dialect ) ) {
|
||||||
|
if ( requiresDialect.matchSubTypes() ) {
|
||||||
|
if ( dialect.getVersion() >= requiresDialect.version() ) {
|
||||||
return ConditionEvaluationResult.enabled( "Matched @RequiresDialect" );
|
return ConditionEvaluationResult.enabled( "Matched @RequiresDialect" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( requiresDialect.value().equals( dialect.getClass() ) ) {
|
if ( requiresDialect.version() == dialect.getVersion() ) {
|
||||||
return ConditionEvaluationResult.enabled( "Matched @RequiresDialect" );
|
return ConditionEvaluationResult.enabled( "Matched @RequiresDialect" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ConditionEvaluationResult.disabled(
|
return ConditionEvaluationResult.disabled(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -94,6 +96,22 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
);
|
);
|
||||||
|
|
||||||
for ( SkipForDialect effectiveSkipForDialect : effectiveSkips ) {
|
for ( SkipForDialect effectiveSkipForDialect : effectiveSkips ) {
|
||||||
|
int version = effectiveSkipForDialect.version();
|
||||||
|
if ( version > -1 ) {
|
||||||
|
if ( effectiveSkipForDialect.dialectClass().isInstance( dialect ) ) {
|
||||||
|
if ( effectiveSkipForDialect.matchSubTypes() ) {
|
||||||
|
if ( dialect.getVersion() <= version ) {
|
||||||
|
return ConditionEvaluationResult.disabled( "Matched @SkipForDialect(group)" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( dialect.getVersion() == version ) {
|
||||||
|
return ConditionEvaluationResult.disabled( "Matched @SkipForDialect" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if ( effectiveSkipForDialect.matchSubTypes() ) {
|
if ( effectiveSkipForDialect.matchSubTypes() ) {
|
||||||
if ( effectiveSkipForDialect.dialectClass().isInstance( dialect ) ) {
|
if ( effectiveSkipForDialect.dialectClass().isInstance( dialect ) ) {
|
||||||
return ConditionEvaluationResult.disabled( "Matched @SkipForDialect(group)" );
|
return ConditionEvaluationResult.disabled( "Matched @SkipForDialect(group)" );
|
||||||
|
@ -105,6 +123,7 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<RequiresDialectFeature> effectiveRequiresDialectFeatures = TestingUtil.findEffectiveRepeatingAnnotation(
|
List<RequiresDialectFeature> effectiveRequiresDialectFeatures = TestingUtil.findEffectiveRepeatingAnnotation(
|
||||||
context,
|
context,
|
||||||
|
@ -118,7 +137,7 @@ public class DialectFilterExtension implements ExecutionCondition {
|
||||||
.newInstance();
|
.newInstance();
|
||||||
final boolean applicable = dialectFeatureCheck.apply( getDialect( context ) );
|
final boolean applicable = dialectFeatureCheck.apply( getDialect( context ) );
|
||||||
final boolean reverse = effectiveRequiresDialectFeature.reverse();
|
final boolean reverse = effectiveRequiresDialectFeature.reverse();
|
||||||
if ( applicable ^ reverse ) {
|
if ( !( applicable ^ reverse ) ) {
|
||||||
return ConditionEvaluationResult.disabled(
|
return ConditionEvaluationResult.disabled(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
|
|
|
@ -21,6 +21,6 @@ public interface EntityManagerFactoryAccess extends DialectAccess {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default Dialect getDialect() {
|
default Dialect getDialect() {
|
||||||
return getEntityManagerFactory().unwrap( SessionFactoryImplementor.class ).getJdbcServices().getDialect();
|
return Dialect.getDialect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* 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.testing.junit5;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public final class ExtraAssertions {
|
||||||
|
private ExtraAssertions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertClassAssignability(Class expected, Class actual) {
|
||||||
|
if ( !expected.isAssignableFrom( actual ) ) {
|
||||||
|
fail( "Expected class [" + expected.getName() + "] was not assignable from actual [" + actual.getName() + "]" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T assertTyping(Class<T> expectedType, Object value) {
|
||||||
|
if ( !expectedType.isInstance( value ) ) {
|
||||||
|
fail(
|
||||||
|
String.format(
|
||||||
|
"Expecting value of type [%s], but found [%s]",
|
||||||
|
expectedType.getName(),
|
||||||
|
value == null ? "<null>" : value
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (T) value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void assertJdbcTypeCode(int expected, int actual) {
|
||||||
|
if ( expected != actual ) {
|
||||||
|
final String message = String.format(
|
||||||
|
"JDBC type codes did not match...\n" +
|
||||||
|
"Expected: %s (%s)\n" +
|
||||||
|
"Actual : %s (%s)",
|
||||||
|
jdbcTypeCodeMap().get( expected ),
|
||||||
|
expected,
|
||||||
|
jdbcTypeCodeMap().get( actual ),
|
||||||
|
actual
|
||||||
|
);
|
||||||
|
fail( message );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<Integer, String> jdbcTypeCodeMap;
|
||||||
|
|
||||||
|
private static synchronized Map<Integer, String> jdbcTypeCodeMap() {
|
||||||
|
if ( jdbcTypeCodeMap == null ) {
|
||||||
|
jdbcTypeCodeMap = generateJdbcTypeCache();
|
||||||
|
}
|
||||||
|
return jdbcTypeCodeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map generateJdbcTypeCache() {
|
||||||
|
final Field[] fields = Types.class.getFields();
|
||||||
|
Map cache = new HashMap( (int) ( fields.length * .75 ) + 1 );
|
||||||
|
for ( Field field : fields ) {
|
||||||
|
if ( Modifier.isStatic( field.getModifiers() ) ) {
|
||||||
|
try {
|
||||||
|
cache.put( field.get( null ), field.getName() );
|
||||||
|
}
|
||||||
|
catch (Throwable ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,4 +39,9 @@ public @interface RequiresDialect {
|
||||||
* Should subtypes of {@link #value()} be matched?
|
* Should subtypes of {@link #value()} be matched?
|
||||||
*/
|
*/
|
||||||
boolean matchSubTypes() default true;
|
boolean matchSubTypes() default true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the Dialect version
|
||||||
|
*/
|
||||||
|
int version();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,5 @@ public @interface SkipForDialect {
|
||||||
Class<? extends Dialect> dialectClass();
|
Class<? extends Dialect> dialectClass();
|
||||||
boolean matchSubTypes() default false;
|
boolean matchSubTypes() default false;
|
||||||
String reason() default "<undefined>";
|
String reason() default "<undefined>";
|
||||||
|
int version() default -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue