Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ stage('Configure') {
if ( pullRequest.labels.contains( 'hana' ) ) {
this.environments.add( new BuildEnvironment( dbName: 'hana_cloud', dbLockableResource: 'hana-cloud', dbLockResourceAsHost: true ) )
}
if ( pullRequest.labels.contains( 'sybase' ) ) {
this.environments.add( new BuildEnvironment( dbName: 'sybase_jconn' ) )
}
}

helper.configure {
Expand Down Expand Up @@ -235,6 +238,13 @@ stage('Build') {
sh "./docker_db.sh sybase"
state[buildEnv.tag]['containerName'] = "sybase"
break;
case "sybase_jconn":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('nguoianphu/docker-sybase').pull()
}
sh "./docker_db.sh sybase"
state[buildEnv.tag]['containerName'] = "sybase"
break;
case "cockroachdb":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('cockroachdb/cockroach:v22.2.2').pull()
Expand All @@ -256,8 +266,11 @@ stage('Build') {
withEnv(["RDBMS=${buildEnv.dbName}"]) {
try {
if (buildEnv.dbLockableResource == null) {
timeout( [time: buildEnv.longRunning ? 480 : 120, unit: 'MINUTES'] ) {
sh cmd
withCredentials([file(credentialsId: 'sybase-jconnect-driver', variable: 'jconnect_driver')]) {
sh 'cp $jconnect_driver ./drivers/jconn4.jar'
timeout( [time: buildEnv.longRunning ? 480 : 120, unit: 'MINUTES'] ) {
sh cmd
}
}
}
else {
Expand Down
2 changes: 2 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ elif [ "$RDBMS" == "mssql" ] || [ "$RDBMS" == "mssql_2017" ]; then
goal="-Pdb=mssql_ci"
elif [ "$RDBMS" == "sybase" ]; then
goal="-Pdb=sybase_ci"
elif [ "$RDBMS" == "sybase_jconn" ]; then
goal="-Pdb=sybase_jconn_ci"
elif [ "$RDBMS" == "tidb" ]; then
goal="-Pdb=tidb"
elif [ "$RDBMS" == "hana_cloud" ]; then
Expand Down
2 changes: 1 addition & 1 deletion gradle/databases.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ext {
'jdbc.user' : 'hibernate_orm_test',
'jdbc.pass' : 'hibernate_orm_test',
// Disable prepared statement caching to avoid issues with changing schemas
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':5000/hibernate_orm_test',
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':9000/hibernate_orm_test',
'connection.init_sql' : 'set ansinull on set quoted_identifier on'
],
mysql : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public boolean canCreateSchema() {

@Override
public String getCurrentSchemaCommand() {
return "select db_name()";
return "select user_name()";
}

@Override
Expand Down Expand Up @@ -477,9 +477,7 @@ public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, D

@Override
public NameQualifierSupport getNameQualifierSupport() {
// No support for schemas: https://userapps.support.sap.com/sap/support/knowledge/en/2591730
// Authorization schemas seem to be something different: https://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36272.1550/html/commands/X48762.htm
return NameQualifierSupport.CATALOG;
return NameQualifierSupport.BOTH;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ private Identifier getCurrentSchema(JdbcEnvironment jdbcEnvironment) {
catch (SQLException ignore) {
LOG.sqlWarning( ignore.getErrorCode(), ignore.getSQLState() );
}
catch (AbstractMethodError ignore) {
// jConnect and jTDS report that they "support" schemas, but they don't really
}
}
return currentSchema;
}
Expand Down Expand Up @@ -498,6 +501,9 @@ private String getCurrentSchemaFilter(JdbcEnvironment jdbcEnvironment) {
catch (SQLException ignore) {
LOG.sqlWarning( ignore.getErrorCode(), ignore.getSQLState() );
}
catch (AbstractMethodError ignore) {
// jConnect and jTDS report that they "support" schemas, but they don't really
}
}
return currentSchemaFilter;
}
Expand All @@ -523,7 +529,7 @@ public NameSpaceTablesInformation getTables(Identifier catalog, Identifier schem
catalogFilter = toMetaDataObjectName( extractionContext.getDefaultCatalog() );
}
else {
catalogFilter = "";
catalogFilter = null;
}
}
}
Expand All @@ -548,7 +554,7 @@ public NameSpaceTablesInformation getTables(Identifier catalog, Identifier schem
schemaFilter = toMetaDataObjectName( extractionContext.getDefaultSchema() );
}
else {
schemaFilter = "";
schemaFilter = null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
*/
package org.hibernate.orm.test.schemamanager;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.tool.schema.spi.SchemaManagementException;

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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.hibernate.testing.orm.junit.SkipForDialect;
import org.hibernate.tool.schema.spi.SchemaManagementException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;

import static org.hibernate.cfg.AvailableSettings.DEFAULT_SCHEMA;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -36,8 +36,8 @@
@DomainModel(annotatedClasses = {SchemaManagerExplicitSchemaTest.Book.class, SchemaManagerExplicitSchemaTest.Author.class})
@SessionFactory(exportSchema = false)
@ServiceRegistry(settings = @Setting(name = DEFAULT_SCHEMA, value = "schema_manager_test"))
@SkipForDialect(dialectClass = OracleDialect.class, reason = "Oracle tests run in the DBO schema")
@RequiresDialectFeature(feature= DialectFeatureChecks.SupportsTruncateTable.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTruncateTable.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportSchemaCreation.class)
public class SchemaManagerExplicitSchemaTest {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.hibernate.orm.test.timezones;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;

import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
Expand All @@ -15,11 +18,9 @@
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -29,8 +30,19 @@
public class AutoZonedTest {

@Test void test(SessionFactoryScope scope) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect ) {
// Sybase has 1/300th sec precision
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") )
.with( ChronoField.NANO_OF_SECOND, 0L );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) )
.with( ChronoField.NANO_OF_SECOND, 0L );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
long id = scope.fromTransaction( s-> {
Zoned z = new Zoned();
z.zonedDateTime = nowZoned;
Expand All @@ -41,21 +53,14 @@ public class AutoZonedTest {
scope.inSession( s -> {
Zoned z = s.find(Zoned.class, id);
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
if ( dialect instanceof SybaseDialect ) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
);
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
);
}
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
);
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
);
assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() );
assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() );
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.hibernate.orm.test.timezones;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;

import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.SybaseDialect;
Expand All @@ -15,11 +18,9 @@
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;

import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -29,8 +30,19 @@
public class ColumnZonedTest {

@Test void test(SessionFactoryScope scope) {
ZonedDateTime nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
OffsetDateTime nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
final ZonedDateTime nowZoned;
final OffsetDateTime nowOffset;
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect ) {
// Sybase has 1/300th sec precision
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") )
.with( ChronoField.NANO_OF_SECOND, 0L );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) )
.with( ChronoField.NANO_OF_SECOND, 0L );
}
else {
nowZoned = ZonedDateTime.now().withZoneSameInstant( ZoneId.of("CET") );
nowOffset = OffsetDateTime.now().withOffsetSameInstant( ZoneOffset.ofHours(3) );
}
long id = scope.fromTransaction( s-> {
Zoned z = new Zoned();
z.zonedDateTime = nowZoned;
Expand All @@ -41,21 +53,14 @@ public class ColumnZonedTest {
scope.inSession( s -> {
Zoned z = s.find(Zoned.class, id);
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
if ( dialect instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
);
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
);
}
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowZoned.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.zonedDateTime.toInstant(), dialect )
);
assertEquals(
DateTimeUtils.roundToDefaultPrecision( nowOffset.toInstant(), dialect ),
DateTimeUtils.roundToDefaultPrecision( z.offsetDateTime.toInstant(), dialect )
);
assertEquals( nowZoned.toOffsetDateTime().getOffset(), z.zonedDateTime.toOffsetDateTime().getOffset() );
assertEquals( nowOffset.getOffset(), z.offsetDateTime.getOffset() );
});
Expand Down
Loading