Re-enabled additional tests
This commit is contained in:
parent
6efb29e98e
commit
7d4df4a01b
|
@ -12,9 +12,9 @@
|
|||
<!--
|
||||
Demonstrates use of a class-level where restriction
|
||||
-->
|
||||
<hibernate-mapping package="org.hibernate.test.nonpkassociation">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.nonpkassociation">
|
||||
|
||||
<class name="org.hibernate.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Parent" table="T_PARENT">
|
||||
<class name="org.hibernate.orm.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Parent" table="T_PARENT">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
|
@ -25,15 +25,17 @@
|
|||
|
||||
<set name="children" inverse="true" cascade="all-delete-orphan">
|
||||
<key column="parentVal"/>
|
||||
<one-to-many class="org.hibernate.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Child"/>
|
||||
<one-to-many class="org.hibernate.orm.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Child"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="org.hibernate.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Child" table="T_CHILD">
|
||||
<class name="org.hibernate.orm.test.nonpkassociation.NonPkManyToOneAssociationHbmTest$Child" table="T_CHILD">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
|
||||
<property name="name"/>
|
||||
|
||||
<many-to-one name="parent" property-ref="collectionKey" not-null="true">
|
||||
<column name="parentVal" />
|
||||
</many-to-one>
|
|
@ -4,32 +4,35 @@
|
|||
* 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.nonpkassociation;
|
||||
package org.hibernate.orm.test.nonpkassociation;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
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.assertEquals;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author pholvs
|
||||
*/
|
||||
public class NonPkManyToOneAssociationHbmTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] { "nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml" };
|
||||
}
|
||||
@DomainModel(
|
||||
xmlMappings = "org/hibernate/orm/test/nonpkassociation/NonPkManyToOneAssociationHbmTest.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
public class NonPkManyToOneAssociationHbmTest {
|
||||
|
||||
private Parent parent;
|
||||
|
||||
@Before
|
||||
public void createTestData() {
|
||||
inTransaction(
|
||||
@BeforeEach
|
||||
public void createTestData(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
parent = new Parent( 99999L );
|
||||
s.persist( parent );
|
||||
|
@ -41,10 +44,20 @@ public class NonPkManyToOneAssociationHbmTest extends BaseCoreFunctionalTestCase
|
|||
);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(SessionFactoryScope scope){
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.createQuery( "delete from NonPkManyToOneAssociationHbmTest$Child" ).executeUpdate();
|
||||
session.createQuery( "delete from NonPkManyToOneAssociationHbmTest$Parent" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHqlWithFetch() {
|
||||
inTransaction(
|
||||
public void testHqlWithFetch(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
Parent dbParent = s.find( Parent.class, this.parent.getId() );
|
||||
Set<Child> children = dbParent.getChildren();
|
||||
|
@ -96,6 +109,16 @@ public class NonPkManyToOneAssociationHbmTest extends BaseCoreFunctionalTestCase
|
|||
|
||||
private Long id;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
private Parent parent;
|
||||
|
||||
public Child(Parent parent) {
|
|
@ -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.nonpkassociation;
|
||||
package org.hibernate.orm.test.nonpkassociation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
@ -17,30 +17,31 @@ import javax.persistence.JoinColumn;
|
|||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author pholvs
|
||||
*/
|
||||
public class NonPkManyToOneAssociationTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
Parent.class,
|
||||
Child.class,
|
||||
};
|
||||
}
|
||||
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
NonPkManyToOneAssociationTest.Parent.class,
|
||||
NonPkManyToOneAssociationTest.Child.class,
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class NonPkManyToOneAssociationTest {
|
||||
private Parent parent;
|
||||
|
||||
@Before
|
||||
public void createTestData() {
|
||||
inTransaction(
|
||||
@BeforeEach
|
||||
public void createTestData(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
parent = new Parent( 99999L );
|
||||
s.persist( parent );
|
||||
|
@ -52,10 +53,20 @@ public class NonPkManyToOneAssociationTest extends BaseCoreFunctionalTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.createQuery( "delete from Child" ).executeUpdate();
|
||||
session.createQuery( "delete from Parent" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHqlWithFetch() {
|
||||
inTransaction(
|
||||
public void testHqlWithFetch(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
s -> {
|
||||
Parent parent = s.find( Parent.class, this.parent.getId() );
|
||||
assertEquals( 1, parent.getChildren().size() );
|
||||
|
@ -114,6 +125,8 @@ public class NonPkManyToOneAssociationTest extends BaseCoreFunctionalTestCase {
|
|||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parentVal", referencedColumnName = "collectionKey")
|
||||
private Parent parent;
|
Loading…
Reference in New Issue