HHH-16528 Revert SybaseDialect NameQualifierSupport to CATALOG only and fix ansinull option for jconnect
This commit is contained in:
parent
aad0c55f9b
commit
203f28e14c
|
@ -88,8 +88,8 @@ ext {
|
||||||
'jdbc.user' : 'hibernate_orm_test',
|
'jdbc.user' : 'hibernate_orm_test',
|
||||||
'jdbc.pass' : 'hibernate_orm_test',
|
'jdbc.pass' : 'hibernate_orm_test',
|
||||||
// Disable prepared statement caching to avoid issues with changing schemas
|
// Disable prepared statement caching to avoid issues with changing schemas
|
||||||
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':5000/hibernate_orm_test?SQLINITSTRING=set quoted_identifier on&SQLINITSTRING=set ANSINULL on',
|
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':5000/hibernate_orm_test',
|
||||||
'connection.init_sql' : ''
|
'connection.init_sql' : 'set ansinull on set quoted_identifier on'
|
||||||
],
|
],
|
||||||
mysql : [
|
mysql : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
|
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
|
||||||
|
|
|
@ -54,10 +54,11 @@ import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.ast.tree.select.SelectStatement;
|
import org.hibernate.sql.ast.tree.select.SelectStatement;
|
||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.type.JavaObjectType;
|
import org.hibernate.type.JavaObjectType;
|
||||||
|
import org.hibernate.type.NullType;
|
||||||
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.ObjectNullAsNullTypeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ObjectNullAsBinaryTypeJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.TinyIntAsSmallIntJdbcType;
|
import org.hibernate.type.descriptor.jdbc.TinyIntAsSmallIntJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
|
@ -191,12 +192,20 @@ public class SybaseLegacyDialect extends AbstractTransactSQLDialect {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcType.PRIMITIVE_ARRAY_BINDING );
|
jdbcTypeRegistry.addDescriptor( Types.BLOB, BlobJdbcType.PRIMITIVE_ARRAY_BINDING );
|
||||||
|
|
||||||
// Sybase requires a custom binder for binding untyped nulls with the NULL type
|
// Sybase requires a custom binder for binding untyped nulls with the NULL type
|
||||||
typeContributions.contributeJdbcType( ObjectNullAsNullTypeJdbcType.INSTANCE );
|
typeContributions.contributeJdbcType( ObjectNullAsBinaryTypeJdbcType.INSTANCE );
|
||||||
|
|
||||||
// Until we remove StandardBasicTypes, we have to keep this
|
// Until we remove StandardBasicTypes, we have to keep this
|
||||||
typeContributions.contributeType(
|
typeContributions.contributeType(
|
||||||
new JavaObjectType(
|
new JavaObjectType(
|
||||||
ObjectNullAsNullTypeJdbcType.INSTANCE,
|
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
|
||||||
|
typeContributions.getTypeConfiguration()
|
||||||
|
.getJavaTypeRegistry()
|
||||||
|
.getDescriptor( Object.class )
|
||||||
|
)
|
||||||
|
);
|
||||||
|
typeContributions.contributeType(
|
||||||
|
new NullType(
|
||||||
|
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
|
||||||
typeContributions.getTypeConfiguration()
|
typeContributions.getTypeConfiguration()
|
||||||
.getJavaTypeRegistry()
|
.getJavaTypeRegistry()
|
||||||
.getDescriptor( Object.class )
|
.getDescriptor( Object.class )
|
||||||
|
@ -356,9 +365,8 @@ public class SybaseLegacyDialect extends AbstractTransactSQLDialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameQualifierSupport getNameQualifierSupport() {
|
public NameQualifierSupport getNameQualifierSupport() {
|
||||||
if ( getVersion().isSameOrAfter( 15 ) ) {
|
// No support for schemas: https://userapps.support.sap.com/sap/support/knowledge/en/2591730
|
||||||
return NameQualifierSupport.BOTH;
|
// 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.CATALOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.ast.tree.select.SelectStatement;
|
import org.hibernate.sql.ast.tree.select.SelectStatement;
|
||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.type.JavaObjectType;
|
import org.hibernate.type.JavaObjectType;
|
||||||
|
import org.hibernate.type.NullType;
|
||||||
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
|
@ -220,6 +221,14 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
||||||
.getDescriptor( Object.class )
|
.getDescriptor( Object.class )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
typeContributions.contributeType(
|
||||||
|
new NullType(
|
||||||
|
ObjectNullAsBinaryTypeJdbcType.INSTANCE,
|
||||||
|
typeContributions.getTypeConfiguration()
|
||||||
|
.getJavaTypeRegistry()
|
||||||
|
.getDescriptor( Object.class )
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -380,12 +389,9 @@ public class SybaseDialect extends AbstractTransactSQLDialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameQualifierSupport getNameQualifierSupport() {
|
public NameQualifierSupport getNameQualifierSupport() {
|
||||||
if ( driverKind == SybaseDriverKind.JTDS ) {
|
// No support for schemas: https://userapps.support.sap.com/sap/support/knowledge/en/2591730
|
||||||
return NameQualifierSupport.CATALOG;
|
// 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;
|
||||||
else {
|
|
||||||
return NameQualifierSupport.BOTH;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,23 +15,23 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.DatabaseVersion;
|
|
||||||
import org.hibernate.dialect.Dialect;
|
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||||
|
import org.hibernate.testing.orm.junit.JiraKey;
|
||||||
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-10635")
|
@JiraKey("HHH-10635")
|
||||||
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsCommentOn.class)
|
||||||
public class CommentGenerationTest {
|
public class CommentGenerationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -39,7 +39,6 @@ public class CommentGenerationTest {
|
||||||
final String resource = "org/hibernate/orm/test/schemaupdate/CommentGeneration.hbm.xml";
|
final String resource = "org/hibernate/orm/test/schemaupdate/CommentGeneration.hbm.xml";
|
||||||
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
.applySetting( Environment.HBM2DDL_AUTO, "none" )
|
.applySetting( Environment.HBM2DDL_AUTO, "none" )
|
||||||
.applySetting( Environment.DIALECT, SupportCommentDialect.class.getName() )
|
|
||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
File output = File.createTempFile( "update_script", ".sql" );
|
File output = File.createTempFile( "update_script", ".sql" );
|
||||||
|
@ -65,16 +64,4 @@ public class CommentGenerationTest {
|
||||||
StandardServiceRegistryBuilder.destroy( ssr );
|
StandardServiceRegistryBuilder.destroy( ssr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SupportCommentDialect extends Dialect{
|
|
||||||
@Override
|
|
||||||
public boolean supportsCommentOn() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DatabaseVersion getVersion() {
|
|
||||||
return ZERO_VERSION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.hibernate.orm.test.schemaupdate.CommentGenerationTest;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -67,7 +66,6 @@ public class StatementsWithoutTerminalCharsImportFileTest extends BaseUnitTestCa
|
||||||
// NOTE : the
|
// NOTE : the
|
||||||
ssr = new StandardServiceRegistryBuilder()
|
ssr = new StandardServiceRegistryBuilder()
|
||||||
.applySetting( Environment.HBM2DDL_AUTO, "none" )
|
.applySetting( Environment.HBM2DDL_AUTO, "none" )
|
||||||
.applySetting( Environment.DIALECT, CommentGenerationTest.SupportCommentDialect.class.getName() )
|
|
||||||
.applySetting(
|
.applySetting(
|
||||||
Environment.HBM2DDL_IMPORT_FILES,
|
Environment.HBM2DDL_IMPORT_FILES,
|
||||||
"/org/hibernate/orm/test/tool/schema/scripts/statements-without-terminal-chars.sql"
|
"/org/hibernate/orm/test/tool/schema/scripts/statements-without-terminal-chars.sql"
|
||||||
|
|
|
@ -658,4 +658,10 @@ abstract public class DialectFeatureChecks {
|
||||||
return dialect instanceof SybaseDialect && ( (SybaseDialect) dialect ).getDriverKind() == SybaseDriverKind.JTDS;
|
return dialect instanceof SybaseDialect && ( (SybaseDialect) dialect ).getDriverKind() == SybaseDriverKind.JTDS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SupportsCommentOn implements DialectFeatureCheck {
|
||||||
|
public boolean apply(Dialect dialect) {
|
||||||
|
return dialect.supportsCommentOn();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue