Skip some tests for databases that don't support a current_timestamp function with microsecond precision
This commit is contained in:
parent
ca22db14bb
commit
1fb839b841
|
@ -22,6 +22,12 @@ import static org.junit.Assert.assertTrue;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractGeneratedPropertyTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected String getBaseForMappings() {
|
||||
return "org/hibernate/orm/test/";
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-2627" )
|
||||
public final void testGeneratedProperty() {
|
||||
|
|
|
@ -31,11 +31,14 @@ import org.hibernate.annotations.Generated;
|
|||
import org.hibernate.annotations.GenerationTime;
|
||||
import org.hibernate.annotations.GeneratorType;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
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.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -44,6 +47,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SkipForDialect(dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "CURRENT_TIMESTAMP not supported as default value in Sybase")
|
||||
@SkipForDialect(dialectClass = MySQLDialect.class, reason = "See HHH-10196")
|
||||
@DomainModel( annotatedClasses = ComplexValueGenerationTests.AuditedEntity.class )
|
||||
@SessionFactory
|
||||
@NotImplementedYet(
|
||||
|
|
|
@ -14,7 +14,9 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.CurrentTimestamp;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
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.junit.jupiter.api.Test;
|
||||
|
@ -26,6 +28,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = CurrentTimestampAnnotationTests.AuditedEntity.class )
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.UsesStandardCurrentTimestampFunction.class, comment = "We rely on current_timestamp being the SQL function name")
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
|
||||
public class CurrentTimestampAnnotationTests {
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
|
|
|
@ -36,8 +36,10 @@ import org.hibernate.annotations.GenerationTime;
|
|||
import org.hibernate.annotations.GeneratorType;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
import org.hibernate.annotations.ValueGenerationType;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.tuple.AnnotationValueGeneration;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
import org.hibernate.tuple.ValueGenerator;
|
||||
|
@ -58,7 +60,7 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@SkipForDialect(value = SybaseDialect.class, comment = "CURRENT_TIMESTAMP not supported as default value in Sybase")
|
||||
@SkipForDialect(value = MySQLDialect.class, comment = "See HHH-10196", strictMatching = false)
|
||||
@SkipForDialect(value = MySQLDialect.class, comment = "See HHH-10196")
|
||||
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
|
||||
@FailureExpected(
|
||||
jiraKey = "",
|
||||
|
|
|
@ -59,7 +59,7 @@ import static org.junit.Assert.assertTrue;
|
|||
* @author Steve Ebersole
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@SkipForDialect( dialectClass = SybaseDialect.class, reason = "CURRENT_TIMESTAMP not supported as default value in Sybase" )
|
||||
@SkipForDialect( dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "CURRENT_TIMESTAMP not supported as default value in Sybase" )
|
||||
@SkipForDialect( dialectClass = MySQLDialect.class, reason = "See HHH-10196" )
|
||||
@NotImplementedYet(
|
||||
strict = false,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.generated">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.mapping.generated">
|
||||
|
||||
<class name="GeneratedPropertyEntity" table="gen_prop">
|
||||
|
||||
|
@ -41,9 +41,7 @@
|
|||
<drop>
|
||||
<![CDATA[DROP TRIGGER t_iu_gen_prop]]>
|
||||
</drop>
|
||||
<dialect-scope name="org.hibernate.dialect.Oracle9iDialect"/>
|
||||
<dialect-scope name="org.hibernate.dialect.Oracle10gDialect"/>
|
||||
<dialect-scope name="org.hibernate.dialect.Oracle12cDialect"/>
|
||||
<dialect-scope name="org.hibernate.dialect.OracleDialect"/>
|
||||
</database-object>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -17,7 +17,9 @@ import org.hibernate.annotations.UpdateTimestamp;
|
|||
import org.hibernate.annotations.CurrentTimestamp;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
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.junit.jupiter.api.AfterEach;
|
||||
|
@ -33,6 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = InDbGenerationsWithAnnotationsTests.AuditedEntity.class )
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.UsesStandardCurrentTimestampFunction.class, comment = "We rely on current_timestamp being the SQL function name")
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
|
||||
public class InDbGenerationsWithAnnotationsTests {
|
||||
@Test
|
||||
public void testGenerations(SessionFactoryScope scope) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.generated">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.mapping.generated">
|
||||
|
||||
<class name="GeneratedPropertyEntity" table="gen_prop">
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
|||
</id>
|
||||
<property name="name"/>
|
||||
<property name="lastModified" generated="always" type="binary">
|
||||
<column name="lastModified" length="8" sql-type="TIMESTAMP"/>
|
||||
<column name="lastModified" length="8" sql-type="timestamp"/>
|
||||
</property>
|
||||
|
||||
</class>
|
||||
|
|
|
@ -20,6 +20,6 @@ import org.hibernate.testing.RequiresDialect;
|
|||
)
|
||||
public class TimestampGeneratedValuesWithCachingTest extends AbstractGeneratedPropertyTest {
|
||||
public final String[] getMappings() {
|
||||
return new String[] { "generated/MSSQLGeneratedPropertyEntity.hbm.xml" };
|
||||
return new String[] { "mapping/generated/MSSQLGeneratedPropertyEntity.hbm.xml" };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
package org.hibernate.orm.test.mapping.generated;
|
||||
|
||||
import org.hibernate.dialect.Oracle9iDialect;
|
||||
import org.hibernate.dialect.OracleDialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
||||
/**
|
||||
|
@ -14,9 +16,9 @@ import org.hibernate.testing.RequiresDialect;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect( value = Oracle9iDialect.class )
|
||||
@RequiresDialect( value = OracleDialect.class )
|
||||
public class TriggerGeneratedValuesWithCachingTest extends AbstractGeneratedPropertyTest {
|
||||
public final String[] getMappings() {
|
||||
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
|
||||
return new String[] { "mapping/generated/GeneratedPropertyEntity.hbm.xml" };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
*/
|
||||
package org.hibernate.orm.test.mapping.generated;
|
||||
|
||||
import org.hibernate.dialect.Oracle9iDialect;
|
||||
import org.hibernate.dialect.OracleDialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect( value = Oracle9iDialect.class )
|
||||
@RequiresDialect( value = OracleDialect.class )
|
||||
public class TriggerGeneratedValuesWithoutCachingTest extends AbstractGeneratedPropertyTest {
|
||||
public final String[] getMappings() {
|
||||
return new String[] { "generated/GeneratedPropertyEntity.hbm.xml" };
|
||||
return new String[] { "mapping/generated/GeneratedPropertyEntity.hbm.xml" };
|
||||
}
|
||||
|
||||
public String getCacheConcurrencyStrategy() {
|
||||
|
|
|
@ -14,7 +14,9 @@ import javax.persistence.Table;
|
|||
import org.hibernate.annotations.CurrentTimestamp;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
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.junit.jupiter.api.Test;
|
||||
|
@ -26,6 +28,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = GeneratedInstantTests.GeneratedInstantEntity.class )
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.UsesStandardCurrentTimestampFunction.class, comment = "We rely on current_timestamp being the SQL function name")
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
|
||||
public class GeneratedInstantTests {
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
|
|
|
@ -12,11 +12,15 @@ import javax.persistence.Id;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.CurrentTimestamp;
|
||||
import org.hibernate.dialect.SybaseASEDialect;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -28,6 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = MultipleGeneratedValuesTests.GeneratedInstantEntity.class )
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
|
||||
@SkipForDialect( dialectClass = SybaseASEDialect.class, matchSubTypes = true, reason = "CURRENT_TIMESTAMP not supported in insert/update in Sybase ASE. Also see https://groups.google.com/g/comp.databases.sybase/c/j-RxPnF3img" )
|
||||
public class MultipleGeneratedValuesTests {
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
|
|
|
@ -11,11 +11,15 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.dialect.SybaseASEDialect;
|
||||
import org.hibernate.tuple.GenerationTiming;
|
||||
|
||||
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;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -27,6 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
@DomainModel( annotatedClasses = ProposedGeneratedTests.GeneratedInstantEntity.class )
|
||||
@SessionFactory
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.CurrentTimestampHasMicrosecondPrecision.class, comment = "Without this, we might not see an update to the timestamp")
|
||||
@SkipForDialect( dialectClass = SybaseASEDialect.class, matchSubTypes = true, reason = "CURRENT_TIMESTAMP not supported in insert/update in Sybase ASE. Also see https://groups.google.com/g/comp.databases.sybase/c/j-RxPnF3img" )
|
||||
public class ProposedGeneratedTests {
|
||||
@Test
|
||||
public void test(SessionFactoryScope scope) {
|
||||
|
|
|
@ -372,4 +372,16 @@ abstract public class DialectFeatureChecks {
|
|||
return ! dialect.doesRepeatableReadCauseReadersToBlockWriters();
|
||||
}
|
||||
}
|
||||
|
||||
public static class CurrentTimestampHasMicrosecondPrecision implements DialectFeatureCheck {
|
||||
public boolean apply(Dialect dialect) {
|
||||
return !dialect.currentTimestamp().contains( "6" );
|
||||
}
|
||||
}
|
||||
|
||||
public static class UsesStandardCurrentTimestampFunction implements DialectFeatureCheck {
|
||||
public boolean apply(Dialect dialect) {
|
||||
return dialect.currentTimestamp().startsWith( "current_timestamp" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue