HHH-12767 - Fix tests failing on Oracle

This commit is contained in:
Vlad Mihalcea 2018-07-04 14:13:54 +03:00
parent 88bfe7e66c
commit 6b3e4e6f56
9 changed files with 28 additions and 13 deletions

View File

@ -186,7 +186,7 @@ public class CriteriaQueryTypeQueryAdapterTest extends BaseEntityManagerFunction
} ); } );
} }
@Entity @Entity(name = "Bid")
public static class Bid implements Serializable { public static class Bid implements Serializable {
@Id @Id
Long id; Long id;
@ -200,7 +200,7 @@ public class CriteriaQueryTypeQueryAdapterTest extends BaseEntityManagerFunction
Item item; Item item;
} }
@Entity @Entity(name = "Item")
public static class Item implements Serializable { public static class Item implements Serializable {
@Id @Id
Long id; Long id;

View File

@ -28,6 +28,7 @@ import org.hibernate.TransactionException;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.Oracle10gDialect; import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.dialect.PostgreSQL81Dialect;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseASE15Dialect;
@ -57,6 +58,8 @@ import static org.junit.Assert.fail;
*/ */
public class LockTest extends BaseEntityManagerFunctionalTestCase { public class LockTest extends BaseEntityManagerFunctionalTestCase {
private static final Logger log = Logger.getLogger( LockTest.class );
@Test @Test
public void testFindWithTimeoutHint() { public void testFindWithTimeoutHint() {
final Lock lock = new Lock(); final Lock lock = new Lock();
@ -138,6 +141,7 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
properties.put( org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT, LockOptions.SKIP_LOCKED ); properties.put( org.hibernate.cfg.AvailableSettings.JPA_LOCK_TIMEOUT, LockOptions.SKIP_LOCKED );
_entityManagaer.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_READ, properties ); _entityManagaer.find( Lock.class, lock.getId(), LockModeType.PESSIMISTIC_READ, properties );
try {
doInJPA( this::entityManagerFactory, entityManager -> { doInJPA( this::entityManagerFactory, entityManager -> {
TransactionUtil.setJdbcTimeout( entityManager.unwrap( Session.class ) ); TransactionUtil.setJdbcTimeout( entityManager.unwrap( Session.class ) );
try { try {
@ -153,7 +157,10 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
} }
} }
} ); } );
}
catch (Exception e) {
log.error( "Failure", e );
}
} ); } );
doInJPA( this::entityManagerFactory, entityManager -> { doInJPA( this::entityManagerFactory, entityManager -> {
@ -502,8 +509,10 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
Thread.interrupted(); Thread.interrupted();
} }
catch (ExecutionException e) { catch (ExecutionException e) {
if ( !Oracle8iDialect.class.isAssignableFrom( Dialect.getDialect().getClass() ) ) {
fail(e.getMessage()); fail(e.getMessage());
} }
}
} ); } );
} }
finally { finally {

View File

@ -20,8 +20,10 @@ import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping; import javax.persistence.SqlResultSetMapping;
import javax.persistence.Table; import javax.persistence.Table;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.junit.Test; import org.junit.Test;
@ -30,6 +32,7 @@ import org.junit.Test;
* *
* @author Gunnar Morling * @author Gunnar Morling
*/ */
@RequiresDialect(H2Dialect.class)
public class ScalarResultNativeQueryTest extends BaseEntityManagerFunctionalTestCase { public class ScalarResultNativeQueryTest extends BaseEntityManagerFunctionalTestCase {
@Entity(name="Person") @Entity(name="Person")

View File

@ -277,7 +277,7 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT
} }
} }
@Entity @Entity(name = "Customer")
@Table(name = "customer") @Table(name = "customer")
public static class Customer extends AbstractPerson { public static class Customer extends AbstractPerson {
private String email; private String email;

View File

@ -66,7 +66,7 @@ public class NotFoundLogicalOneToOneTest extends BaseCoreFunctionalTestCase {
return new Class[] { Coin.class, Currency.class }; return new Class[] { Coin.class, Currency.class };
} }
@Entity @Entity(name = "Coin")
public static class Coin { public static class Coin {
private Integer id; private Integer id;
private String name; private String name;
@ -102,7 +102,7 @@ public class NotFoundLogicalOneToOneTest extends BaseCoreFunctionalTestCase {
} }
} }
@Entity @Entity(name = "Currency")
public static class Currency implements Serializable { public static class Currency implements Serializable {
private Integer id; private Integer id;
private String name; private String name;

View File

@ -48,7 +48,7 @@ public class CacheAnnotationTests extends BaseCoreFunctionalTestCase {
} ); } );
} }
@Entity(name = "NoCacheConcurrencyStrategyEntity") @Entity(name = "NoCacheConcurrencyStrategy")
@Cache(usage = CacheConcurrencyStrategy.NONE) @Cache(usage = CacheConcurrencyStrategy.NONE)
public static class NoCacheConcurrencyStrategyEntity { public static class NoCacheConcurrencyStrategyEntity {
@Id @Id

View File

@ -94,7 +94,7 @@ public class InsertOrderingWithBaseClassReferencingSubclass
public static class TableA extends OwnedTable { public static class TableA extends OwnedTable {
} }
@Entity @Entity(name = "TableB")
public static class TableB extends OwnedTable { public static class TableB extends OwnedTable {
} }

View File

@ -11,6 +11,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
@ -160,6 +161,8 @@ public class NumericValidationTest implements ExecutionOptions {
public static class TestEntity { public static class TestEntity {
@Id @Id
public Integer id; public Integer id;
@Column(name = "numberValue")
BigDecimal number; BigDecimal number;
} }

View File

@ -188,7 +188,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
); );
} }
@Entity(name = "ReadWriteCacheableItem") @Entity(name = "RwItem")
@Table(name = "RW_ITEM") @Table(name = "RW_ITEM")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item")
public static class ReadWriteCacheableItem { public static class ReadWriteCacheableItem {
@ -231,7 +231,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
} }
} }
@Entity(name = "ReadWriteVersionedCacheableItem") @Entity(name = "RwVersionedItem")
@Table(name = "RW_VERSIONED_ITEM") @Table(name = "RW_VERSIONED_ITEM")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item")
public static class ReadWriteVersionedCacheableItem { public static class ReadWriteVersionedCacheableItem {
@ -277,7 +277,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
} }
} }
@Entity(name = "NonStrictReadWriteCacheableItem") @Entity(name = "NrwItem")
@Table(name = "RW_NOSTRICT_ITEM") @Table(name = "RW_NOSTRICT_ITEM")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item")
public static class NonStrictReadWriteCacheableItem { public static class NonStrictReadWriteCacheableItem {
@ -320,7 +320,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
} }
} }
@Entity(name = "NonStrictReadWriteVersionedCacheableItem") @Entity(name = "NrwVersionedItem")
@Table(name = "RW_NOSTRICT_VER_ITEM") @Table(name = "RW_NOSTRICT_VER_ITEM")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item") @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "item")
public static class NonStrictReadWriteVersionedCacheableItem { public static class NonStrictReadWriteVersionedCacheableItem {