Re-enabled additional tests
This commit is contained in:
parent
2622ce70d2
commit
3f87ed17ee
|
@ -4,7 +4,7 @@
|
|||
* 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.test.idgen.userdefined;
|
||||
package org.hibernate.orm.test.idgen.userdefined;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
@ -40,15 +40,18 @@ import org.hibernate.resource.beans.container.spi.ContainedBean;
|
|||
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-14688")
|
||||
public class UserDefinedGeneratorsTests extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class UserDefinedGeneratorsTests {
|
||||
|
||||
@Test
|
||||
public void testCreateGeneratorsByBeanContainer() {
|
||||
|
@ -104,7 +107,7 @@ public class UserDefinedGeneratorsTests extends BaseUnitTestCase {
|
|||
public static class Entity1 {
|
||||
@Id
|
||||
@GeneratedValue( generator = "test" )
|
||||
@GenericGenerator( name = "test", strategy = "org.hibernate.test.idgen.userdefined.UserDefinedGeneratorsTests$TestIdentifierGenerator" )
|
||||
@GenericGenerator( name = "test", strategy = "org.hibernate.orm.test.idgen.userdefined.UserDefinedGeneratorsTests$TestIdentifierGenerator" )
|
||||
private Integer id;
|
||||
}
|
||||
|
||||
|
@ -113,7 +116,7 @@ public class UserDefinedGeneratorsTests extends BaseUnitTestCase {
|
|||
public static class Entity2 {
|
||||
@Id
|
||||
@GeneratedValue( generator = "test" )
|
||||
@GenericGenerator( name = "test", strategy = "org.hibernate.test.idgen.userdefined.UserDefinedGeneratorsTests$TestIdentifierGenerator" )
|
||||
@GenericGenerator( name = "test", strategy = "org.hibernate.orm.test.idgen.userdefined.UserDefinedGeneratorsTests$TestIdentifierGenerator" )
|
||||
private Integer id;
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.persistence.Column;
|
||||
|
@ -23,15 +23,17 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
|||
import org.hibernate.mapping.PersistentClass;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ColumnDefinitionQuotingTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class ColumnDefinitionQuotingTest {
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-9491" )
|
||||
public void testExplicitQuoting() {
|
|
@ -10,9 +10,9 @@
|
|||
SYSTEM
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.quote">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.quote">
|
||||
<typedef name="enumType" class="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.hibernate.test.quote.DataPoint$DataPointEnum</param>
|
||||
<param name="enumClass">org.hibernate.orm.test.quote.DataPoint$DataPointEnum</param>
|
||||
</typedef>
|
||||
|
||||
<class name="DataPoint">
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* 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.quote;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
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.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
User.class,
|
||||
Role.class,
|
||||
Phone.class,
|
||||
Person.class,
|
||||
House.class
|
||||
},
|
||||
xmlMappings = "org/hibernate/orm/test/quote/DataPoint.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
@ServiceRegistry(
|
||||
settings = @Setting(name = AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, value = "true")
|
||||
)
|
||||
public class QuoteGlobalTest {
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-7890")
|
||||
public void testQuotedUniqueConstraint(SessionFactoryScope scope) {
|
||||
Iterator<UniqueKey> itr = scope.getMetadataImplementor().getEntityBinding( Person.class.getName() )
|
||||
.getTable().getUniqueKeyIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
UniqueKey uk = itr.next();
|
||||
assertEquals( 1, uk.getColumns().size() );
|
||||
assertEquals( "name", uk.getColumn( 0 ).getName() );
|
||||
return;
|
||||
}
|
||||
fail( "GLOBALLY_QUOTED_IDENTIFIERS caused the unique key creation to fail." );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuoteManytoMany(SessionFactoryScope scope) {
|
||||
scope.inSession(
|
||||
session -> {
|
||||
try {
|
||||
Transaction tx = session.beginTransaction();
|
||||
User u = new User();
|
||||
session.persist( u );
|
||||
Role r = new Role();
|
||||
session.persist( r );
|
||||
u.getRoles().add( r );
|
||||
session.flush();
|
||||
session.clear();
|
||||
u = session.get( User.class, u.getId() );
|
||||
assertEquals( 1, u.getRoles().size() );
|
||||
tx.rollback();
|
||||
String role = User.class.getName() + ".roles";
|
||||
assertEquals(
|
||||
"User_Role",
|
||||
scope.getMetadataImplementor()
|
||||
.getCollectionBinding( role )
|
||||
.getCollectionTable()
|
||||
.getName()
|
||||
);
|
||||
}
|
||||
finally {
|
||||
if ( session.getTransaction().isActive() ) {
|
||||
session.getTransaction().rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-8520")
|
||||
public void testHbmQuoting(SessionFactoryScope scope) {
|
||||
final MetadataImplementor metadataImplementor = scope.getMetadataImplementor();
|
||||
doTestHbmQuoting( DataPoint.class, metadataImplementor );
|
||||
doTestHbmQuoting( AssociatedDataPoint.class, metadataImplementor );
|
||||
}
|
||||
|
||||
private void doTestHbmQuoting(Class clazz, MetadataImplementor metadataImplementor) {
|
||||
Table table = metadataImplementor.getEntityBinding( clazz.getName() ).getTable();
|
||||
assertTrue( table.isQuoted() );
|
||||
Iterator itr = table.getColumnIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
Column column = (Column) itr.next();
|
||||
assertTrue( column.isQuoted() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -21,7 +21,6 @@ import javax.persistence.OneToMany;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
|
@ -20,6 +20,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
|
||||
import org.hibernate.orm.test.util.DdlTransactionIsolatorTestingImpl;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaValidator;
|
||||
import org.hibernate.tool.schema.internal.SchemaCreatorImpl;
|
||||
import org.hibernate.tool.schema.internal.SchemaDropperImpl;
|
||||
|
@ -27,28 +28,29 @@ import org.hibernate.tool.schema.internal.exec.GenerationTarget;
|
|||
import org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.orm.test.util.DdlTransactionIsolatorTestingImpl;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableGeneratorQuotingTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class TableGeneratorQuotingTest {
|
||||
private StandardServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
serviceRegistry = new StandardServiceRegistryBuilder()
|
||||
.applySetting( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, "true" )
|
||||
.build();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if ( serviceRegistry != null ) {
|
||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
|
@ -58,7 +60,8 @@ public class TableGeneratorQuotingTest extends BaseUnitTestCase {
|
|||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-7927")
|
||||
public void testTableGeneratorQuoting() {
|
||||
final Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( TestEntity.class ).buildMetadata();
|
||||
final Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( TestEntity.class )
|
||||
.buildMetadata();
|
||||
|
||||
final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.quote;
|
||||
package org.hibernate.orm.test.quote;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
|
@ -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.typeoverride">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.typeoverride">
|
||||
|
||||
<class name="Entity">
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.typeoverride;
|
||||
package org.hibernate.orm.test.typeoverride;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.typeoverride;
|
||||
package org.hibernate.orm.test.typeoverride;
|
||||
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.typeoverride;
|
||||
package org.hibernate.orm.test.typeoverride;
|
||||
|
||||
import java.sql.Types;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* 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.test.typeoverride;
|
||||
package org.hibernate.orm.test.typeoverride;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
|
@ -4,33 +4,44 @@
|
|||
* 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.test.typeoverride;
|
||||
package org.hibernate.orm.test.typeoverride;
|
||||
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.dialect.AbstractHANADialect;
|
||||
import org.hibernate.dialect.CockroachDialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.type.descriptor.jdbc.BlobTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.IntegerTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.VarbinaryTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
|
||||
|
||||
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.dialect.*;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.type.descriptor.jdbc.*;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
|
||||
public class TypeOverrideTest extends BaseSessionFactoryFunctionalTest {
|
||||
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
return new String[] { "typeoverride/Entity.hbm.xml" };
|
||||
protected String[] getOrmXmlFiles() {
|
||||
return new String[] { "org/hibernate/orm/test/typeoverride/Entity.hbm.xml" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
cfg.registerTypeOverride( StoredPrefixedStringType.INSTANCE );
|
||||
protected void applyMetadataBuilder(MetadataBuilder metadataBuilder) {
|
||||
metadataBuilder.applyBasicType( StoredPrefixedStringType.INSTANCE );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,7 +71,8 @@ public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
|
|||
else if ( AbstractHANADialect.class.isInstance( getDialect() ) ) {
|
||||
assertSame(
|
||||
( (AbstractHANADialect) getDialect() ).getBlobTypeDescriptor(),
|
||||
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT ) );
|
||||
getDialect().remapSqlTypeDescriptor( BlobTypeDescriptor.DEFAULT )
|
||||
);
|
||||
}
|
||||
else {
|
||||
assertSame(
|
||||
|
@ -86,7 +98,10 @@ public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
|
|||
public void testDialectWithNonStandardSqlTypeDescriptor() {
|
||||
assertNotSame( VarcharTypeDescriptor.INSTANCE, StoredPrefixedStringType.INSTANCE.getJdbcTypeDescriptor() );
|
||||
final Dialect dialect = new H2DialectOverridePrefixedVarcharSqlTypeDesc();
|
||||
final JdbcTypeDescriptor remapped = remapSqlTypeDescriptor( dialect, StoredPrefixedStringType.PREFIXED_VARCHAR_TYPE_DESCRIPTOR );
|
||||
final JdbcTypeDescriptor remapped = remapSqlTypeDescriptor(
|
||||
dialect,
|
||||
StoredPrefixedStringType.PREFIXED_VARCHAR_TYPE_DESCRIPTOR
|
||||
);
|
||||
assertSame( VarcharTypeDescriptor.INSTANCE, remapped );
|
||||
}
|
||||
|
||||
|
@ -98,48 +113,53 @@ public class TypeOverrideTest extends BaseCoreFunctionalTestCase {
|
|||
return dialect.remapSqlTypeDescriptor( jdbcTypeDescriptor );
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
inTransaction(
|
||||
session ->
|
||||
session.createQuery( "delete from Entity" ).executeUpdate()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsert() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Entity e = new Entity( "name" );
|
||||
s.save( e );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
session ->
|
||||
session.save( e )
|
||||
);
|
||||
|
||||
s = openSession();
|
||||
s.getTransaction().begin();
|
||||
e = ( Entity ) s.get( Entity.class, e.getId() );
|
||||
assertFalse( e.getName().startsWith( StoredPrefixedStringType.PREFIX ) );
|
||||
assertEquals( "name", e.getName() );
|
||||
s.delete( e );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
session -> {
|
||||
Entity entity = session.get( Entity.class, e.getId() );
|
||||
assertFalse( entity.getName().startsWith( StoredPrefixedStringType.PREFIX ) );
|
||||
assertEquals( "name", entity.getName() );
|
||||
session.delete( entity );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SkipForDialect( value = SybaseASE15Dialect.class, jiraKey = "HHH-6426")
|
||||
@SkipForDialect(dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "HHH-6426")
|
||||
public void testRegisteredFunction() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Entity e = new Entity( "name " );
|
||||
s.save( e );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
session ->
|
||||
session.save( e )
|
||||
);
|
||||
|
||||
s = openSession();
|
||||
s.getTransaction().begin();
|
||||
e = ( Entity ) s.get( Entity.class, e.getId() );
|
||||
assertFalse( e.getName().startsWith( StoredPrefixedStringType.PREFIX ) );
|
||||
assertEquals( "name ", e.getName() );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
session -> {
|
||||
Entity entity = session.get( Entity.class, e.getId() );
|
||||
assertFalse( entity.getName().startsWith( StoredPrefixedStringType.PREFIX ) );
|
||||
assertEquals( "name ", entity.getName() );
|
||||
}
|
||||
);
|
||||
|
||||
s = openSession();
|
||||
s.getTransaction().begin();
|
||||
s.delete( e );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
inTransaction(
|
||||
session ->
|
||||
session.delete( e )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +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.test.quote;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
public class QuoteGlobalTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-7890")
|
||||
public void testQuotedUniqueConstraint() {
|
||||
Iterator<UniqueKey> itr = metadata().getEntityBinding( Person.class.getName() )
|
||||
.getTable().getUniqueKeyIterator();
|
||||
while ( itr.hasNext() ) {
|
||||
UniqueKey uk = itr.next();
|
||||
assertEquals( uk.getColumns().size(), 1 );
|
||||
assertEquals( uk.getColumn( 0 ).getName(), "name");
|
||||
return;
|
||||
}
|
||||
fail( "GLOBALLY_QUOTED_IDENTIFIERS caused the unique key creation to fail." );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuoteManytoMany() {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
User u = new User();
|
||||
s.persist( u );
|
||||
Role r = new Role();
|
||||
s.persist( r );
|
||||
u.getRoles().add( r );
|
||||
s.flush();
|
||||
s.clear();
|
||||
u = (User) s.get( User.class, u.getId() );
|
||||
assertEquals( 1, u.getRoles().size() );
|
||||
tx.rollback();
|
||||
String role = User.class.getName() + ".roles";
|
||||
assertEquals( "User_Role", metadata().getCollectionBinding( role ).getCollectionTable().getName() );
|
||||
s.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-8520")
|
||||
public void testHbmQuoting() {
|
||||
doTestHbmQuoting( DataPoint.class );
|
||||
doTestHbmQuoting( AssociatedDataPoint.class );
|
||||
}
|
||||
|
||||
private void doTestHbmQuoting(Class clazz) {
|
||||
Table table = metadata().getEntityBinding( clazz.getName() ).getTable();
|
||||
assertTrue( table.isQuoted() );
|
||||
Iterator itr = table.getColumnIterator();
|
||||
while(itr.hasNext()) {
|
||||
Column column = (Column) itr.next();
|
||||
assertTrue( column.isQuoted() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSettings(Map settings) {
|
||||
settings.put( AvailableSettings.GLOBALLY_QUOTED_IDENTIFIERS, "true" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
User.class,
|
||||
Role.class,
|
||||
Phone.class,
|
||||
Person.class,
|
||||
House.class
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getMappings() {
|
||||
return new String[] { "quote/DataPoint.hbm.xml" };
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue