Migrate more tests from jpa/test to orm/test/jpa
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
56d90a0aa9
commit
2fb1cdcae1
|
@ -1,60 +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.jpa.test.lob;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.DialectChecks;
|
||||
import org.hibernate.testing.RequiresDialectFeature;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@RequiresDialectFeature( DialectChecks.SupportsExpectedLobUsagePattern.class )
|
||||
public class BlobTest extends BaseEntityManagerFunctionalTestCase {
|
||||
@Test
|
||||
public void testBlobSerialization() throws Exception {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
Map<String,String> image = new HashMap<String, String>();
|
||||
image.put( "meta", "metadata" );
|
||||
image.put( "data", "imagedata" );
|
||||
ImageReader reader = new ImageReader();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream( baos );
|
||||
oos.writeObject( image );
|
||||
reader.setImage( em.unwrap( Session.class ).getLobHelper().createBlob( baos.toByteArray() ) );
|
||||
em.persist( reader );
|
||||
em.getTransaction().commit();
|
||||
em.close(); //useless but y'a know
|
||||
em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
reader = em.find( ImageReader.class, reader.getId() );
|
||||
ObjectInputStream ois = new ObjectInputStream( reader.getImage().getBinaryStream() );
|
||||
image = (HashMap<String, String>) ois.readObject();
|
||||
assertTrue( image.containsKey( "meta" ) );
|
||||
em.getTransaction().commit();
|
||||
em.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class[] getAnnotatedClasses() {
|
||||
return new Class[] { ImageReader.class };
|
||||
}
|
||||
}
|
|
@ -1,59 +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.jpa.test.mapping;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ColumnWithExplicitReferenceToPrimaryTableTest extends BaseUnitTestCase {
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-8539" )
|
||||
public void testColumnAnnotationWithExplicitReferenceToPrimaryTable() {
|
||||
final PersistenceUnitDescriptorAdapter pu = new PersistenceUnitDescriptorAdapter() {
|
||||
@Override
|
||||
public List<String> getManagedClassNames() {
|
||||
return Arrays.asList( AnEntity.class.getName() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
final Map settings = new HashMap();
|
||||
settings.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||
|
||||
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder( pu, settings ).build();
|
||||
emf.close();
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table( name = "THE_TABLE" )
|
||||
public static class AnEntity {
|
||||
@Id
|
||||
public Integer id;
|
||||
@Column( name = "THE_COLUMN", table = "THE_TABLE" )
|
||||
public String theValue;
|
||||
}
|
||||
}
|
|
@ -1,72 +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.jpa.test.mapping;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class DefaultCascadeTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
public void testCascadePersist() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
Parent parent = new Parent();
|
||||
Child child = new Child();
|
||||
child.parent = parent;
|
||||
|
||||
entityManager.persist( child );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getEjb3DD() {
|
||||
return new String[] {
|
||||
"org/hibernate/jpa/test/mapping/orm.xml"
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Parent.class,
|
||||
Child.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "Parent")
|
||||
public static class Parent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "Child")
|
||||
public static class Child {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@ManyToOne
|
||||
private Parent parent;
|
||||
}
|
||||
}
|
|
@ -1,110 +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.jpa.test.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.IndexColumn;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.transaction.TransactionUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-1268")
|
||||
public class UnidirectionalOneToManyIndexColumnTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] { Parent.class, Child.class };
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingAChild() {
|
||||
int parentId = TransactionUtil.doInHibernate( this::sessionFactory, session -> {
|
||||
Parent parent = new Parent();
|
||||
parent.getChildren().add( new Child() );
|
||||
parent.getChildren().add( new Child() );
|
||||
parent.getChildren().add( new Child() );
|
||||
session.persist( parent );
|
||||
return parent.getId();
|
||||
} );
|
||||
|
||||
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
|
||||
Parent parent = session.find( Parent.class, parentId );
|
||||
List<Child> children = parent.getChildren();
|
||||
assertThat( children.size(), is( 3 ) );
|
||||
children.remove( 0 );
|
||||
session.persist( parent );
|
||||
} );
|
||||
|
||||
TransactionUtil.doInHibernate( this::sessionFactory, session -> {
|
||||
Parent parent = session.find( Parent.class, parentId );
|
||||
List<Child> children = parent.getChildren();
|
||||
assertThat( children.size(), is( 2 ) );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "PARENT")
|
||||
public static class Parent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@OneToMany(targetEntity = Child.class, cascade = CascadeType.ALL)
|
||||
@IndexColumn(name = "position")
|
||||
private List<Child> children = new ArrayList<>();
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Child> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Child> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "CHILD")
|
||||
public static class Child {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,183 +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.jpa.test.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-11587")
|
||||
public class UnidirectionalOneToManyOrderColumnTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
public void testRemovingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingAndAddingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
} );
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i++ ));
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingOneAndAddingTwoElements() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
children.add( new ChildData( "Another Another" ) );
|
||||
} );
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i++ ));
|
||||
assertEquals( "Another Another", childIds.get( i++ ));
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
ParentData.class,
|
||||
ChildData.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity(name = "ParentData")
|
||||
@Table(name = "PARENT")
|
||||
public static class ParentData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OrderColumn(name = "listOrder")
|
||||
private List<ChildData> children = new ArrayList<>();
|
||||
|
||||
public List<ChildData> getChildren() {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "ChildData")
|
||||
@Table(name = "CHILD")
|
||||
public static class ChildData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
String childId;
|
||||
|
||||
public ChildData() {
|
||||
}
|
||||
|
||||
public ChildData(String id) {
|
||||
childId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return childId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,173 +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.jpa.test.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-1268")
|
||||
public class UnidirectionalOneToManyUniqueConstraintOrderColumnTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected void afterEntityManagerFactoryBuilt() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
parent.id = 1L;
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testAddingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingAndAddingAnElement() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
} );
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<String> childIds = parent.getChildren()
|
||||
.stream()
|
||||
.map( ChildData::toString )
|
||||
.collect( Collectors.toList() );
|
||||
|
||||
int i = 0;
|
||||
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i ));
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingOneAndAddingTwoElements() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
children.add( new ChildData( "Another Another" ) );
|
||||
} );
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
List<String> childIds = parent.getChildren()
|
||||
.stream()
|
||||
.map( ChildData::toString )
|
||||
.collect( Collectors.toList() );
|
||||
|
||||
int i = 0;
|
||||
|
||||
assertEquals( "Two", childIds.get( i++ ) );
|
||||
assertEquals( "Another", childIds.get( i++ ) );
|
||||
assertEquals( "Three", childIds.get( i++ ) );
|
||||
assertEquals( "Another Another", childIds.get( i ) );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
ParentData.class,
|
||||
ChildData.class
|
||||
};
|
||||
}
|
||||
|
||||
@Entity(name = "ParentData")
|
||||
public static class ParentData {
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "parentId", nullable = false)
|
||||
@OrderColumn(name = "listOrder")
|
||||
private List<ChildData> children = new ArrayList<>();
|
||||
|
||||
public List<ChildData> getChildren() {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "ChildData")
|
||||
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "parentId", "listOrder" }) })
|
||||
public static class ChildData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
String childId;
|
||||
|
||||
public ChildData() {
|
||||
}
|
||||
|
||||
public ChildData(String id) {
|
||||
childId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return childId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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.jpa.lob;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.Session;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsExpectedLobUsagePattern.class)
|
||||
@Jpa(annotatedClasses = {
|
||||
ImageReader.class
|
||||
})
|
||||
public class BlobTest {
|
||||
@Test
|
||||
public void testBlobSerialization(EntityManagerFactoryScope scope) {
|
||||
Long readerId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream( baos )) {
|
||||
Map<String, String> image = new HashMap<>();
|
||||
image.put( "meta", "metadata" );
|
||||
image.put( "data", "imagedata" );
|
||||
ImageReader reader = new ImageReader();
|
||||
oos.writeObject( image );
|
||||
reader.setImage( entityManager.unwrap( Session.class )
|
||||
.getLobHelper()
|
||||
.createBlob( baos.toByteArray() ) );
|
||||
entityManager.persist( reader );
|
||||
return reader.getId();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ImageReader reader = entityManager.find( ImageReader.class, readerId );
|
||||
try (ObjectInputStream ois = new ObjectInputStream( reader.getImage().getBinaryStream() )) {
|
||||
Map<String, String> image = (HashMap<String, String>) ois.readObject();
|
||||
assertTrue( image.containsKey( "meta" ) );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.jpa.test.lob;
|
||||
package org.hibernate.orm.test.jpa.lob;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Blob;
|
||||
import java.sql.Clob;
|
|
@ -4,61 +4,67 @@
|
|||
* 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.jpa.test.mapping;
|
||||
package org.hibernate.orm.test.jpa.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
@JiraKey(value = "HHH-13287")
|
||||
@Jpa(annotatedClasses = {
|
||||
BidirectionalOneToManyNotNullableColumnTest.ParentData.class,
|
||||
BidirectionalOneToManyNotNullableColumnTest.ChildData.class
|
||||
})
|
||||
public class BidirectionalOneToManyNotNullableColumnTest {
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
entityManager.createQuery( "delete from ChildData" ).executeUpdate();
|
||||
entityManager.createQuery( "delete from ParentData" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-13287")
|
||||
public class BidirectionalOneToManyNotNullableColumnTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-13287" )
|
||||
public void test() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
public void test(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
parent.setId( 1L );
|
||||
parent.addChildData( new ChildData() );
|
||||
parent.addChildData( new ChildData() );
|
||||
|
||||
ParentData parent = new ParentData();
|
||||
parent.setId( 1L );
|
||||
parent.addChildData( new ChildData() );
|
||||
parent.addChildData( new ChildData() );
|
||||
entityManager.persist( parent );
|
||||
}
|
||||
);
|
||||
|
||||
entityManager.persist( parent );
|
||||
} );
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
assertSame( 2, parent.getChildren().size() );
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
ParentData.class,
|
||||
ChildData.class
|
||||
};
|
||||
assertSame( 2, parent.getChildren().size() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity(name = "ParentData")
|
||||
|
@ -116,5 +122,4 @@ public class BidirectionalOneToManyNotNullableColumnTest extends BaseEntityManag
|
|||
this.parentData = parentData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.jpa.mapping;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Jpa(
|
||||
annotatedClasses = {
|
||||
ColumnWithExplicitReferenceToPrimaryTableTest.AnEntity.class
|
||||
},
|
||||
integrationSettings = { @Setting(name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop") }
|
||||
)
|
||||
public class ColumnWithExplicitReferenceToPrimaryTableTest {
|
||||
@Test
|
||||
@JiraKey( value = "HHH-8539" )
|
||||
public void testColumnAnnotationWithExplicitReferenceToPrimaryTable(EntityManagerFactoryScope scope) {
|
||||
Assertions.assertNotNull( scope.getEntityManagerFactory() );
|
||||
scope.getEntityManagerFactory().close();
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table( name = "THE_TABLE" )
|
||||
public static class AnEntity {
|
||||
@Id
|
||||
public Integer id;
|
||||
@Column( name = "THE_COLUMN", table = "THE_TABLE" )
|
||||
public String theValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* 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.jpa.mapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@Jpa(
|
||||
annotatedClasses = {
|
||||
DefaultCascadeTest.Parent.class,
|
||||
DefaultCascadeTest.Child.class
|
||||
},
|
||||
// using 'xmlMappings = { "org/hibernate/orm/test/jpa/mapping/orm.xml" }' also works
|
||||
nonStringValueSettingProviders = { DefaultCascadeTest.EJB3DDMappingProvider.class }
|
||||
)
|
||||
public class DefaultCascadeTest {
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
entityManager.createQuery( "delete from DefaultCascadeTest$Child" ).executeUpdate();
|
||||
entityManager.createQuery( "delete from DefaultCascadeTest$Parent" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCascadePersist(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
Parent parent = new Parent();
|
||||
Child child = new Child();
|
||||
child.parent = parent;
|
||||
|
||||
entityManager.persist( child );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "Parent")
|
||||
public static class Parent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "Child")
|
||||
public static class Child {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@ManyToOne
|
||||
private Parent parent;
|
||||
}
|
||||
|
||||
public static class EJB3DDMappingProvider extends NonStringValueSettingProvider {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.XML_FILE_NAMES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return Arrays.asList( "org/hibernate/orm/test/jpa/mapping/orm.xml" );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* 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.jpa.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.IndexColumn;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@JiraKey( value = "HHH-1268")
|
||||
@Jpa(
|
||||
annotatedClasses = {
|
||||
UnidirectionalOneToManyIndexColumnTest.Parent.class,
|
||||
UnidirectionalOneToManyIndexColumnTest.Child.class
|
||||
},
|
||||
integrationSettings = {
|
||||
@Setting(name = AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, value = "true"),
|
||||
@Setting(name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop"),
|
||||
@Setting(name = AvailableSettings.IMPLICIT_NAMING_STRATEGY, value = "org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl")
|
||||
}
|
||||
)
|
||||
public class UnidirectionalOneToManyIndexColumnTest {
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
entityManager.createQuery( "delete from UnidirectionalOneToManyIndexColumnTest$Parent" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingAChild(EntityManagerFactoryScope scope) {
|
||||
int parentId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
Parent parent = new Parent();
|
||||
parent.getChildren().add( new Child() );
|
||||
parent.getChildren().add( new Child() );
|
||||
parent.getChildren().add( new Child() );
|
||||
entityManager.persist( parent );
|
||||
return parent.getId();
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
Parent parent = entityManager.find( Parent.class, parentId );
|
||||
List<Child> children = parent.getChildren();
|
||||
assertThat( children.size(), is( 3 ) );
|
||||
children.remove( 0 );
|
||||
entityManager.persist( parent );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
Parent parent = entityManager.find( Parent.class, parentId );
|
||||
List<Child> children = parent.getChildren();
|
||||
assertThat( children.size(), is( 2 ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "PARENT")
|
||||
public static class Parent {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
@OneToMany(targetEntity = Child.class, cascade = CascadeType.ALL)
|
||||
@IndexColumn(name = "position")
|
||||
private List<Child> children = new ArrayList<>();
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Child> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Child> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Table(name = "CHILD")
|
||||
public static class Child {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* 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.jpa.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@JiraKey(value = "HHH-11587")
|
||||
@Jpa(annotatedClasses = {
|
||||
UnidirectionalOneToManyOrderColumnTest.ParentData.class,
|
||||
UnidirectionalOneToManyOrderColumnTest.ChildData.class
|
||||
})
|
||||
public class UnidirectionalOneToManyOrderColumnTest {
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
entityManager.createQuery( "delete from ParentData" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingAnElement(EntityManagerFactoryScope scope) {
|
||||
long parentId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
return parent.id;
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, parentId );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i ));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddingAnElement(EntityManagerFactoryScope scope) {
|
||||
long parentId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
return parent.id;
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, parentId );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "One", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i ));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingAndAddingAnElement(EntityManagerFactoryScope scope) {
|
||||
long parentId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
return parent.id;
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, parentId );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i ));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemovingOneAndAddingTwoElements(EntityManagerFactoryScope scope) {
|
||||
long parentId = scope.fromTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
entityManager.persist( child );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
|
||||
entityManager.flush();
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
children.add( new ChildData( "Another Another" ) );
|
||||
return parent.id;
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, parentId );
|
||||
List<String> childIds = parent.getChildren().stream().map( ChildData::toString ).collect( Collectors.toList() );
|
||||
int i = 0;
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i++ ));
|
||||
assertEquals( "Another Another", childIds.get( i ));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity(name = "ParentData")
|
||||
@Table(name = "PARENT")
|
||||
public static class ParentData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@OrderColumn(name = "listOrder")
|
||||
private List<ChildData> children = new ArrayList<>();
|
||||
|
||||
public List<ChildData> getChildren() {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "ChildData")
|
||||
@Table(name = "CHILD")
|
||||
public static class ChildData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
String childId;
|
||||
|
||||
public ChildData() {
|
||||
}
|
||||
|
||||
public ChildData(String id) {
|
||||
childId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return childId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* 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.jpa.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@JiraKey(value = "HHH-1268")
|
||||
@Jpa(annotatedClasses = {
|
||||
UnidirectionalOneToManyUniqueConstraintOrderColumnTest.ParentData.class,
|
||||
UnidirectionalOneToManyUniqueConstraintOrderColumnTest.ChildData.class
|
||||
})
|
||||
public class UnidirectionalOneToManyUniqueConstraintOrderColumnTest {
|
||||
|
||||
@BeforeAll
|
||||
protected void init(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = new ParentData();
|
||||
parent.id = 1L;
|
||||
entityManager.persist( parent );
|
||||
|
||||
String[] childrenStr = new String[] {"One", "Two", "Three"};
|
||||
for ( String str : childrenStr ) {
|
||||
ChildData child = new ChildData( str );
|
||||
parent.getChildren().add( child );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingAnElement(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testAddingAnElement(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingAndAddingAnElement(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<String> childIds = parent.getChildren()
|
||||
.stream()
|
||||
.map( ChildData::toString )
|
||||
.collect( Collectors.toList() );
|
||||
|
||||
int i = 0;
|
||||
|
||||
assertEquals( "Two", childIds.get( i++ ));
|
||||
assertEquals( "Another", childIds.get( i++ ));
|
||||
assertEquals( "Three", childIds.get( i ));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpected( jiraKey = "HHH-1268" )
|
||||
public void testRemovingOneAndAddingTwoElements(EntityManagerFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
|
||||
List<ChildData> children = parent.getChildren();
|
||||
children.remove( 0 );
|
||||
children.add( 1, new ChildData( "Another" ) );
|
||||
children.add( new ChildData( "Another Another" ) );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inEntityManager(
|
||||
entityManager -> {
|
||||
ParentData parent = entityManager.find( ParentData.class, 1L );
|
||||
List<String> childIds = parent.getChildren()
|
||||
.stream()
|
||||
.map( ChildData::toString )
|
||||
.collect( Collectors.toList() );
|
||||
|
||||
int i = 0;
|
||||
|
||||
assertEquals( "Two", childIds.get( i++ ) );
|
||||
assertEquals( "Another", childIds.get( i++ ) );
|
||||
assertEquals( "Three", childIds.get( i++ ) );
|
||||
assertEquals( "Another Another", childIds.get( i ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity(name = "ParentData")
|
||||
public static class ParentData {
|
||||
@Id
|
||||
long id;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "parentId", nullable = false)
|
||||
@OrderColumn(name = "listOrder")
|
||||
private List<ChildData> children = new ArrayList<>();
|
||||
|
||||
public List<ChildData> getChildren() {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "ChildData")
|
||||
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "parentId", "listOrder" }) })
|
||||
public static class ChildData {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
String childId;
|
||||
|
||||
public ChildData() {
|
||||
}
|
||||
|
||||
public ChildData(String id) {
|
||||
childId = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return childId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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.jpa.test.metagen.mappedsuperclass.attribute;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.attribute;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.attribute;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.attribute;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
@ -13,16 +13,17 @@ import org.hibernate.jpa.AvailableSettings;
|
|||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
|
||||
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.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-5024" )
|
||||
public class MappedSuperclassWithAttributesTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class MappedSuperclassWithAttributesTest {
|
||||
@Test
|
||||
public void testStaticMetamodel() {
|
||||
EntityManagerFactory emf = TestingEntityManagerFactoryGenerator.generateEntityManagerFactory(
|
||||
|
@ -30,10 +31,10 @@ public class MappedSuperclassWithAttributesTest extends BaseUnitTestCase {
|
|||
Arrays.asList( Product.class )
|
||||
);
|
||||
try {
|
||||
assertNotNull( "'Product_.id' should not be null)", Product_.id );
|
||||
assertNotNull( "'Product_.name' should not be null)", Product_.name );
|
||||
assertNotNull( Product_.id, "'Product_.id' should not be null)" );
|
||||
assertNotNull( Product_.name, "'Product_.name' should not be null)" );
|
||||
|
||||
assertNotNull( "'AbstractNameable_.name' should not be null)", AbstractNameable_.name );
|
||||
assertNotNull( AbstractNameable_.name, "'AbstractNameable_.name' should not be null)" );
|
||||
}
|
||||
finally {
|
||||
emf.close();
|
|
@ -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.jpa.test.metagen.mappedsuperclass.attribute;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.attribute;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.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.jpa.test.metagen.mappedsuperclass.embedded;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embedded;
|
||||
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.MappedSuperclass;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.embedded;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embedded;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
|
@ -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.jpa.test.metagen.mappedsuperclass.embedded;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embedded;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.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.jpa.test.metagen.mappedsuperclass.embedded;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embedded;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
|
@ -12,17 +12,18 @@ import java.util.Arrays;
|
|||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MappedSuperclassWithEmbeddedTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class MappedSuperclassWithEmbeddedTest {
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-5024" )
|
||||
public void testStaticMetamodel() {
|
||||
|
@ -31,10 +32,10 @@ public class MappedSuperclassWithEmbeddedTest extends BaseUnitTestCase {
|
|||
Arrays.asList( Company.class )
|
||||
);
|
||||
try {
|
||||
assertNotNull( "'Company_.id' should not be null)", Company_.id );
|
||||
assertNotNull( "'Company_.address' should not be null)", Company_.address );
|
||||
assertNotNull( Company_.id, "'Company_.id' should not be null)" );
|
||||
assertNotNull( Company_.address, "'Company_.address' should not be null)" );
|
||||
|
||||
assertNotNull( "'AbstractAddressable_.address' should not be null)", AbstractAddressable_.address );
|
||||
assertNotNull( AbstractAddressable_.address, "'AbstractAddressable_.address' should not be null)" );
|
||||
}
|
||||
finally {
|
||||
emf.close();
|
|
@ -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.jpa.test.metagen.mappedsuperclass.embeddedid;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embeddedid;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.EmbeddedId;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.embeddedid;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embeddedid;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
|
@ -12,17 +12,18 @@ import java.util.Arrays;
|
|||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MappedSuperclassWithEmbeddedIdTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class MappedSuperclassWithEmbeddedIdTest {
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-5024" )
|
||||
public void testStaticMetamodel() {
|
||||
|
@ -32,13 +33,13 @@ public class MappedSuperclassWithEmbeddedIdTest extends BaseUnitTestCase {
|
|||
);
|
||||
|
||||
try {
|
||||
assertNotNull( "'Product_.description' should not be null)", Product_.description );
|
||||
assertNotNull( "'Product_.id' should not be null)", Product_.id );
|
||||
assertNotNull( Product_.description, "'Product_.description' should not be null)" );
|
||||
assertNotNull( Product_.id, "'Product_.id' should not be null)" );
|
||||
|
||||
assertNotNull( "'AbstractProduct_.id' should not be null)", AbstractProduct_.id );
|
||||
assertNotNull( AbstractProduct_.id, "'AbstractProduct_.id' should not be null)" );
|
||||
|
||||
assertNotNull( "'ProductId_.id' should not be null)", ProductId_.id );
|
||||
assertNotNull( "'ProductId_.code' should not be null)", ProductId_.code );
|
||||
assertNotNull( ProductId_.id, "'ProductId_.id' should not be null)" );
|
||||
assertNotNull( ProductId_.code, "'ProductId_.code' should not be null)" );
|
||||
}
|
||||
finally {
|
||||
emf.close();
|
|
@ -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.jpa.test.metagen.mappedsuperclass.embeddedid;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embeddedid;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.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.jpa.test.metagen.mappedsuperclass.embeddedid;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.embeddedid;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.idclass;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.idclass;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.MappedSuperclass;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.idclass;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import java.util.Arrays;
|
||||
|
@ -12,18 +12,19 @@ import java.util.Arrays;
|
|||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
import org.hibernate.jpa.AvailableSettings;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Alexis Bataille
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MappedSuperclassWithEntityWithIdClassTest extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class MappedSuperclassWithEntityWithIdClassTest {
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-5024" )
|
||||
public void testStaticMetamodel() {
|
||||
|
@ -33,11 +34,11 @@ public class MappedSuperclassWithEntityWithIdClassTest extends BaseUnitTestCase
|
|||
);
|
||||
|
||||
try {
|
||||
assertNotNull( "'ProductAttribute_.value' should not be null)", ProductAttribute_.value );
|
||||
assertNotNull( "'ProductAttribute_.owner' should not be null)", ProductAttribute_.owner );
|
||||
assertNotNull( "'ProductAttribute_.key' should not be null)", ProductAttribute_.key );
|
||||
assertNotNull( ProductAttribute_.value, "'ProductAttribute_.value' should not be null)" );
|
||||
assertNotNull( ProductAttribute_.owner, "'ProductAttribute_.owner' should not be null)" );
|
||||
assertNotNull( ProductAttribute_.key, "'ProductAttribute_.key' should not be null)" );
|
||||
|
||||
assertNotNull( "'AbstractAttribute_.value' should not be null)", AbstractAttribute_.value );
|
||||
assertNotNull( AbstractAttribute_.value, "'AbstractAttribute_.value' should not be null)" );
|
||||
}
|
||||
finally {
|
||||
emf.close();
|
|
@ -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.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.idclass;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.idclass;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.idclass;
|
||||
|
||||
/**
|
||||
* @author Alexis Bataille
|
|
@ -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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.overridden;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.overridden;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
@ -12,19 +12,20 @@ import javax.persistence.EntityManagerFactory;
|
|||
import org.hibernate.jpa.AvailableSettings;
|
||||
import org.hibernate.jpa.test.TestingEntityManagerFactoryGenerator;
|
||||
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Oliver Breidenbach
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-11078")
|
||||
public class MappedSuperclassWithOverriddenAttributeTest
|
||||
extends BaseUnitTestCase {
|
||||
@BaseUnitTest
|
||||
public class MappedSuperclassWithOverriddenAttributeTest {
|
||||
|
||||
@Test
|
||||
@FailureExpected(jiraKey = "HHH-11078")
|
||||
|
@ -35,13 +36,13 @@ public class MappedSuperclassWithOverriddenAttributeTest
|
|||
);
|
||||
try {
|
||||
assertNotNull(
|
||||
"'Product1_.overridenName' should not be null)",
|
||||
Product1_.overridenName
|
||||
Product1_.overridenName,
|
||||
"'Product1_.overridenName' should not be null)"
|
||||
);
|
||||
|
||||
assertNotNull(
|
||||
"'Product2_.overridenName' should not be null)",
|
||||
Product2_.overridenName
|
||||
Product2_.overridenName,
|
||||
"'Product2_.overridenName' should not be null)"
|
||||
); // is null
|
||||
}
|
||||
finally {
|
|
@ -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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.overridden;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
|
@ -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.jpa.test.metagen.mappedsuperclass.overridden;
|
||||
package org.hibernate.orm.test.jpa.metagen.mappedsuperclass.overridden;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
|
@ -14,7 +14,7 @@ import org.hibernate.cfg.AvailableSettings;
|
|||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter;
|
||||
import org.hibernate.jpa.test.mapping.ColumnWithExplicitReferenceToPrimaryTableTest.AnEntity;
|
||||
import org.hibernate.orm.test.jpa.mapping.ColumnWithExplicitReferenceToPrimaryTableTest.AnEntity;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.logger.LoggerInspectionRule;
|
||||
import org.hibernate.testing.logger.Triggerable;
|
||||
|
|
Loading…
Reference in New Issue