HHH-12108 - Fix tests failing on Oracle

This commit is contained in:
Vlad Mihalcea 2017-11-20 17:51:32 +02:00
parent 5b710533f7
commit 7f70dccc71
13 changed files with 294 additions and 331 deletions

View File

@ -21,8 +21,10 @@ import javax.persistence.ManyToOne;
import org.hibernate.Session;
import org.hibernate.annotations.NaturalId;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
@ -30,6 +32,7 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
/**
* @author Vlad Mihalcea
*/
@SkipForDialect(Oracle8iDialect.class)
public class EmbeddableOverrideTest extends BaseEntityManagerFunctionalTestCase {
@Override

View File

@ -568,6 +568,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
}
@Entity(name = "OnDeleteUnidirectionalOneToManyParent")
@javax.persistence.Table(name = "OneToManyParent")
public static class OnDeleteUnidirectionalOneToManyParent {
@Id
@ -581,6 +582,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
}
@Entity(name = "OnDeleteUnidirectionalOneToManyChild")
@javax.persistence.Table(name = "OneToManyChild")
public static class OnDeleteUnidirectionalOneToManyChild {
@Id
@ -589,6 +591,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
}
@Entity(name = "OnDeleteUnidirectionalOneToMany")
@javax.persistence.Table(name = "OneToMany")
public static class OnDeleteUnidirectionalOneToMany {
@Id
@ -600,6 +603,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
}
@Entity(name = "ParentUnawareChild")
@javax.persistence.Table(name = "Child")
public static class ParentUnawareChild {
@Id

View File

@ -38,10 +38,6 @@ public class UniqueConstraintThrowsConstraintViolationExceptionTest extends Base
return new Class[] { Customer.class };
}
protected void configure(Configuration configuration) {
configuration.setProperty( Environment.HBM2DDL_AUTO, "update" );
}
@Test
public void testUniqueConstraintWithEmptyColumnName() {
doInHibernate( this::sessionFactory, session -> {

View File

@ -63,7 +63,7 @@ public class CascadeDetachedTest extends BaseCoreFunctionalTestCase {
public static class Book {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
Long id;
String isbn;
@ -91,7 +91,7 @@ public class CascadeDetachedTest extends BaseCoreFunctionalTestCase {
public static class Author {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
Long id;
String firstName;

View File

@ -56,7 +56,7 @@ public class DirtyTrackingNonUpdateableTest extends BaseCoreFunctionalTestCase {
public class Thing {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
long id;
@Version

View File

@ -83,7 +83,7 @@ public class LazyInCacheTest extends BaseCoreFunctionalTestCase {
private static class Order {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
Long id;
@OneToMany
@ -102,7 +102,7 @@ public class LazyInCacheTest extends BaseCoreFunctionalTestCase {
private static class Product {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
Long id;
String name;
@ -113,7 +113,7 @@ public class LazyInCacheTest extends BaseCoreFunctionalTestCase {
private static class Tag {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY )
@GeneratedValue( strategy = GenerationType.AUTO )
Long id;
String name;

View File

@ -10,6 +10,7 @@ import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@ -30,19 +31,20 @@ public class LGMB_From {
@Column(length = 50, nullable = false)
private String name;
// Lazy-Attribut without LazyGroup-Annotation (therefore Default-LazyGroup)
@Column(length = 65000, columnDefinition = "text")
// Lazy-Attribute without LazyGroup-Annotation (therefore Default-LazyGroup)
@Column(length = 65000)
@Basic(fetch = FetchType.LAZY)
@Lob
private String bigText;
// Lazy-Assoziation with mappdedBy in own LazyGroup
// Lazy-Association with mappdedBy in own LazyGroup
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "fromRelation", optional = true)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup(value = "toRelationLazyGroup")
private LGMB_To toRelation;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(nullable = false)
private Long id;

View File

@ -18,11 +18,9 @@ import org.hibernate.annotations.AccessType;
@Entity
@Table(name = "LGMB_TO")
public class LGMB_To {
@Id
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(nullable = false)
@AccessType("property")
private Long id;

View File

@ -68,8 +68,8 @@ public class LazyGroupMappedByTest extends BaseCoreFunctionalTestCase {
public Long createEntities() {
return doInHibernate(
this::sessionFactory, session -> {
session.createNativeQuery( "DELETE FROM LGMB_TO" ).executeUpdate();
session.createNativeQuery( "DELETE FROM LGMB_FROM" ).executeUpdate();
session.createQuery( "delete from LGMB_To" ).executeUpdate();
session.createQuery( "delete from LGMB_From" ).executeUpdate();
LGMB_From from = new LGMB_From( "A" );
LGMB_To to = new LGMB_To( "B" );

View File

@ -179,7 +179,7 @@ public class EmptyCompositeManyToOneKeyTest extends BaseCoreFunctionalTestCase {
private OtherEntity otherEntity;
}
@Entity
@Entity(name = "OtherEntity")
public static class OtherEntity implements Serializable {
@Id
private String firstName;

View File

@ -525,7 +525,7 @@ public class ForeignKeyConstraintTest extends BaseNonConfigCoreFunctionalTestCas
public abstract class PlanItem {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@GeneratedValue(strategy= GenerationType.AUTO)
private Integer id;
public Integer getId() {
@ -541,7 +541,7 @@ public class ForeignKeyConstraintTest extends BaseNonConfigCoreFunctionalTestCas
@SecondaryTable( name = "Task" )
public class Task extends PlanItem {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
@ElementCollection

View File

@ -7,36 +7,27 @@
package org.hibernate.test.insertordering;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
import org.hibernate.test.util.jdbc.PreparedStatementSpyConnectionProvider;
import org.junit.Test;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/**
@ -90,7 +81,7 @@ public class InsertOrderingDuplicateTest
SaleDocument correction = new SaleDocument();
session.persist(correction);
saleDocument.setCorerctionSubject(correction);
saleDocument.setCorerctionsubject( correction);
} );
}
@ -158,14 +149,15 @@ public class InsertOrderingDuplicateTest
@GeneratedValue
private Long id;
@Column(name = "sale_number")
private String number;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "saleDocument")
private Set<SaleDocumentItem> items = new HashSet();
private Set<SaleDocumentItem> items = new HashSet<>();
@JoinColumn(name = "ID_SALE_DOCUMENT_CORRECTION", nullable = true)
@ManyToOne(fetch = FetchType.LAZY)
private SaleDocument corerctionSubject;
private SaleDocument corerctionsubject;
private BigDecimal totalPrice;
@ -206,12 +198,12 @@ public class InsertOrderingDuplicateTest
sdi.setSaleDocument( this );
}
public SaleDocument getCorerctionSubject() {
return corerctionSubject;
public SaleDocument getCorerctionsubject() {
return corerctionsubject;
}
public void setCorerctionSubject(SaleDocument corerctionSubject) {
this.corerctionSubject = corerctionSubject;
public void setCorerctionsubject(SaleDocument corerctionsubject) {
this.corerctionsubject = corerctionsubject;
}
}
@ -293,10 +285,12 @@ public class InsertOrderingDuplicateTest
@Id
@GeneratedValue
private Long id;
@Column(name = "sale_number")
private String number;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "summary")
private Set<SaleDocumentItem> items = new HashSet();
private Set<SaleDocumentItem> items = new HashSet<>();
private BigDecimal totalPrice;