From 3a9c578a14f92c1d8538787cd29a98d4db299a85 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 26 Feb 2020 09:37:19 +0000 Subject: [PATCH] Add test --- ...cadeMergeToProxyEntityCopyAllowedTest.java | 7 +- .../orm/test/cascade/RefreshTest.java | 2 + .../ManyToManyUnidirectionalFetchTest.java | 223 ++++++++++++++++ .../onetomany/OneToManySelfReferenceTest.java | 242 ++++++++++++++++++ .../java/org/hibernate/test/cascade/A.java | 104 -------- .../org/hibernate/test/cascade/Child.hbm.xml | 17 -- .../org/hibernate/test/cascade/Child.java | 36 --- .../ChildForParentWithAssignedId.hbm.xml | 17 -- .../test/cascade/DeleteOrphanChild.hbm.xml | 17 -- .../test/cascade/DeleteOrphanChild.java | 36 --- .../java/org/hibernate/test/cascade/G.java | 95 ------- .../java/org/hibernate/test/cascade/H.java | 94 ------- .../org/hibernate/test/cascade/Job.hbm.xml | 24 -- .../java/org/hibernate/test/cascade/Job.java | 61 ----- .../hibernate/test/cascade/JobBatch.hbm.xml | 26 -- .../org/hibernate/test/cascade/JobBatch.java | 60 ----- .../test/cascade/MultiPathCascade.hbm.xml | 73 ------ .../org/hibernate/test/cascade/Parent.hbm.xml | 24 -- .../org/hibernate/test/cascade/Parent.java | 45 ---- .../test/cascade/ParentWithAssignedId.hbm.xml | 20 -- 20 files changed, 472 insertions(+), 751 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/manytomany/ManyToManyUnidirectionalFetchTest.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManySelfReferenceTest.java delete mode 100755 hibernate-core/src/test/java/org/hibernate/test/cascade/A.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Child.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Child.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/ChildForParentWithAssignedId.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.java delete mode 100755 hibernate-core/src/test/java/org/hibernate/test/cascade/G.java delete mode 100755 hibernate-core/src/test/java/org/hibernate/test/cascade/H.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Job.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Job.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/MultiPathCascade.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.hbm.xml delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/test/cascade/ParentWithAssignedId.hbm.xml diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java index 263b279c9e..8b3cb06119 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java @@ -27,6 +27,8 @@ import javax.persistence.Transient; import javax.persistence.TypedQuery; import javax.persistence.Version; +import org.hibernate.cfg.AvailableSettings; + import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.ServiceRegistry; @@ -35,6 +37,7 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -51,7 +54,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; @ServiceRegistry( settings = { @ServiceRegistry.Setting( - name = "AvailableSettings.MERGE_ENTITY_COPY_OBSERVER", value = "allow" + name = AvailableSettings.MERGE_ENTITY_COPY_OBSERVER, value = "allow" ) } ) @@ -237,7 +240,7 @@ public class CascadeMergeToProxyEntityCopyAllowedTest { }) private Project project; - @ManyToMany(targetEntity = Speaker.class, fetch = FetchType.LAZY, cascade = { + @ManyToMany(targetEntity = Speaker.class,fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REFRESH }) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/RefreshTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/RefreshTest.java index 166dedcb93..822e578c7a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/RefreshTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/RefreshTest.java @@ -13,6 +13,7 @@ import java.util.Iterator; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.Test; @@ -32,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; } ) @SessionFactory +@FailureExpected( reason = "This should be fixed by Nathan PR") public class RefreshTest { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/manytomany/ManyToManyUnidirectionalFetchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/manytomany/ManyToManyUnidirectionalFetchTest.java new file mode 100644 index 0000000000..d2f0b343f8 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/manytomany/ManyToManyUnidirectionalFetchTest.java @@ -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.manytomany; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.TypedQuery; + +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.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * @author Andrea Boriero + */ +@DomainModel( + annotatedClasses = { + ManyToManyUnidirectionalFetchTest.Event.class, + ManyToManyUnidirectionalFetchTest.Speaker.class + } +) +@SessionFactory +public class ManyToManyUnidirectionalFetchTest { + + @BeforeEach + public void setup(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + Event event = new Event( 1L, "Hibernate" ); + session.save( event ); + } + ); + } + + @AfterEach + public void tearDown(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + Event event = session.get( Event.class, 1L ); + session.delete( event ); + } + ); + } + + @Test + public void testJoinFetchEmptyCollection(SessionFactoryScope scope) { + scope.inTransaction( + sesison -> { + TypedQuery query = sesison.createQuery( + "SELECT e FROM Event e LEFT JOIN FETCH e.speakers WHERE e.id = :oid", Event.class ); + query.setParameter( "oid", 1L ); + Event event = query.getSingleResult(); + assertNotNull( event ); + assertEquals( 0, event.getSpeakers().size() ); + } + ); + } + + @Test + public void testJoinEmptyCollection(SessionFactoryScope scope) { + scope.inTransaction( + sesison -> { + TypedQuery query = sesison.createQuery( + "SELECT e FROM Event e LEFT JOIN e.speakers WHERE e.id = :oid", Event.class ); + query.setParameter( "oid", 1L ); + Event event = query.getSingleResult(); + assertNotNull( event ); + Set speakers = event.getSpeakers(); + assertEquals( 0, speakers.size() ); + } + ); + } + + @Test + public void testJoinFetch(SessionFactoryScope scope) { + addSpeakerToEvent( scope ); + scope.inTransaction( + sesison -> { + TypedQuery query = sesison.createQuery( + "SELECT e FROM Event e LEFT JOIN FETCH e.speakers WHERE e.id = :oid", Event.class ); + query.setParameter( "oid", 1L ); + Event event = query.getSingleResult(); + assertNotNull( event ); + Set speakers = event.getSpeakers(); + assertEquals( 1, speakers.size() ); + assertThat( speakers.iterator().next().getName(), is( "Steve" ) ); + } + ); + } + + @Test + public void testJoin(SessionFactoryScope scope) { + addSpeakerToEvent( scope ); + scope.inTransaction( + sesison -> { + TypedQuery query = sesison.createQuery( + "SELECT e FROM Event e LEFT JOIN e.speakers WHERE e.id = :oid", Event.class ); + query.setParameter( "oid", 1L ); + Event event = query.getSingleResult(); + assertNotNull( event ); + Set speakers = event.getSpeakers(); + + assertEquals( 1, speakers.size() ); + + assertThat( speakers.iterator().next().getName(), is( "Steve" ) ); + } + ); + } + + private void addSpeakerToEvent(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + Event event = session.get( Event.class, 1l ); + Speaker speaker = new Speaker( 2l, "Steve" ); + event.addSpeaker( speaker ); + session.save( speaker ); + } + ); + } + + @Entity(name = "Event") + public static class Event { + + @Id + private Long id; + + private String name; + + public Event() { + } + + public Event(Long id, String name) { + this.id = id; + this.name = name; + } + + @ManyToMany(targetEntity = Speaker.class, fetch = FetchType.LAZY, cascade = { + CascadeType.PERSIST, + CascadeType.REFRESH, + CascadeType.REMOVE + }) + private Set speakers = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Set getSpeakers() { + return Collections.unmodifiableSet( speakers ); + } + + public void setSpeakers(Set speakers) { + this.speakers = speakers; + } + + public void addSpeaker(Speaker speaker) { + this.speakers.add( speaker ); + } + } + + @Entity(name = "Speaker") + public static class Speaker { + + @Id + private Long id; + + private String name; + + public Speaker() { + } + + public Speaker(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManySelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManySelfReferenceTest.java new file mode 100644 index 0000000000..01cf4d0637 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManySelfReferenceTest.java @@ -0,0 +1,242 @@ +/* + * 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.onetomany; + +import java.util.HashSet; +import java.util.Set; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.TypedQuery; + +import org.hibernate.Hibernate; +import org.hibernate.collection.internal.PersistentSet; + +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.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.sameInstance; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @author Andrea Boriero + */ +@DomainModel( + annotatedClasses = { + OneToManySelfReferenceTest.Event.class + } +) +@SessionFactory +public class OneToManySelfReferenceTest { + + @BeforeEach + public void setUp(SessionFactoryScope scope) { + Event parent = new Event(); + scope.inTransaction( + session -> { + parent.setName( "parent" ); + parent.setId( 1L ); + + Event child = new Event(); + child.setId( 2L ); + child.setName( "child" ); + + parent.addChid( child ); + + session.save( parent ); + session.save( child ); + } + ); + } + + @AfterEach + public void tearDown(SessionFactoryScope scope) { + scope.inTransaction( + session -> + session.createQuery( "delete from Event" ).executeUpdate() + ); + } + + @Test + public void testSelectParentFetchChildren(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + TypedQuery eventTypedQuery = session.createQuery( + "SELECT e FROM Event e left join fetch e.children WHERE e.id = :oid", + Event.class + ); + + eventTypedQuery.setParameter( "oid", 1L ); + + Event event = eventTypedQuery.getSingleResult(); + Set children = event.getChildren(); + assertTrue( + Hibernate.isInitialized( children ), + "Children collection has not been initialized" + ); + assertThat( children.size(), is( 1 ) ); + + assertThat( children, instanceOf( PersistentSet.class ) ); + PersistentSet persistentSet = (PersistentSet) children; + assertThat( persistentSet.getKey(), is(1L) ); + + Event child = children.iterator().next(); + Set childChildren = child.getChildren(); + assertFalse( + Hibernate.isInitialized( childChildren ), + "Child children collection should not be initialized" + ); + assertThat( childChildren, instanceOf( PersistentSet.class ) ); + PersistentSet childChildrenPersistentSet = (PersistentSet) childChildren; + assertThat( childChildrenPersistentSet.getKey(), is(2L) ); + + assertThat( childChildren.size(), is(0) ); + assertTrue( + Hibernate.isInitialized( childChildren ), + "Child children collection should not be initialized" + ); + } + ); + } + + @Test + public void testSelectParent(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + TypedQuery eventTypedQuery = session.createQuery( + "SELECT e FROM Event e WHERE e.id = :oid", + Event.class + ); + + eventTypedQuery.setParameter( "oid", 1L ); + + Event event = eventTypedQuery.getSingleResult(); + Set children = event.getChildren(); + assertFalse( + Hibernate.isInitialized( children ), + "Children collection should not be initialized" + ); + assertThat( children.size(), is( 1 ) ); + assertTrue( + Hibernate.isInitialized( children ), + "Children collection has not been initialized" + ); + Event child = children.iterator().next(); + Set childChildren = child.getChildren(); + assertFalse( + Hibernate.isInitialized( childChildren ), + "Child children collection should not be initialized" + ); + assertThat( childChildren, instanceOf( PersistentSet.class ) ); + PersistentSet childChildrenPersistentSet = (PersistentSet) childChildren; + assertThat( childChildrenPersistentSet.getKey(), is(2L) ); + + assertThat( childChildren.size(), is(0) ); + } + ); + } + + @Test + public void testSelectChild(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + TypedQuery eventTypedQuery = session.createQuery( + "SELECT e FROM Event e left join fetch e.children WHERE e.id = :oid", + Event.class + ); + + eventTypedQuery.setParameter( "oid", 2L ); + + Event event = eventTypedQuery.getSingleResult(); + Set children = event.getChildren(); + assertTrue( + Hibernate.isInitialized( children ), + "Children collection has not been initialized" + ); + assertThat( children.size(), is( 0 ) ); + assertThat( children, instanceOf( PersistentSet.class ) ); + PersistentSet childrenPersistentSet = (PersistentSet) children; + assertThat( childrenPersistentSet.getKey(), is(2L) ); + + Event parent = event.getParent(); + assertThat( parent.getId(), is(1L) ); + Set parentChildren = parent.getChildren(); + assertFalse( + Hibernate.isInitialized( parentChildren ), + "Child children collection should not be initialized" + ); + PersistentSet parentChildrenPersistentSet = (PersistentSet) parentChildren; + assertThat( parentChildrenPersistentSet.getKey(), is(1L) ); + + Event next = parentChildren.iterator().next(); + assertThat( next, sameInstance(event) ); + } + ); + } + + + @Entity(name = "Event") + public static class Event { + + private Long id; + + private String name; + + private Event parent; + + private Set children = new HashSet<>(); + + @Id + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @ManyToOne(targetEntity = Event.class) + public Event getParent() { + return parent; + } + + public void setParent(Event parent) { + this.parent = parent; + } + + @OneToMany(targetEntity = Event.class, mappedBy = "parent") + public Set getChildren() { + return children; + } + + public void setChildren(Set children) { + this.children = children; + } + + public void addChid(Event event) { + this.children.add( event ); + event.setParent( this ); + } + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/A.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/A.java deleted file mode 100755 index 653f5e6fd6..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/A.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.cascade; - -import java.util.HashSet; -import java.util.Set; - -public class A -{ - // Constants ----------------------------------------------------------------------------------- - - // Static -------------------------------------------------------------------------------------- - - // Attributes ---------------------------------------------------------------------------------- - - private long id; - - private String data; - - // A 1 - * H - private Set hs; - - // A 1 - 1 G - private G g; - - - // Constructors -------------------------------------------------------------------------------- - - public A() - { - hs = new HashSet(); - } - - public A(String data) - { - this(); - this.data = data; - } - - // Public -------------------------------------------------------------------------------------- - - public long getId() - { - return id; - } - - public void setId(long id) - { - this.id = id; - } - - public void setData(String data) - { - this.data = data; - } - - public String getData() - { - return data; - } - - public void setHs(Set hs) - { - this.hs = hs; - } - - public Set getHs() - { - return hs; - } - - public void setG(G g) - { - this.g = g; - } - - public G getG() - { - return g; - } - - public void addH(H h) - { - hs.add(h); - h.setA(this); - } - - public String toString() - { - return "A[" + id + ", " + data + "]"; - } - - // Package protected --------------------------------------------------------------------------- - - // Protected ----------------------------------------------------------------------------------- - - // Private ------------------------------------------------------------------------------------- - - // Inner classes ------------------------------------------------------------------------------- -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.hbm.xml deleted file mode 100644 index 3d520b8124..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.hbm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.java deleted file mode 100644 index 632c34f24c..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Child.java +++ /dev/null @@ -1,36 +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 . - */ -package org.hibernate.test.cascade; - - -/** - * Created by IntelliJ IDEA. - * User: Gail - * Date: Jan 2, 2007 - * Time: 4:51:29 PM - * To change this template use File | Settings | File Templates. - */ -public class Child { - private Long id; - private Parent parent; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Parent getParent() { - return parent; - } - - public void setParent(Parent parent) { - this.parent = parent; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/ChildForParentWithAssignedId.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/ChildForParentWithAssignedId.hbm.xml deleted file mode 100644 index bcd4e34386..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/ChildForParentWithAssignedId.hbm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.hbm.xml deleted file mode 100644 index 21b4108b5c..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.hbm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.java deleted file mode 100644 index 0a34eab28d..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/DeleteOrphanChild.java +++ /dev/null @@ -1,36 +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 . - */ -package org.hibernate.test.cascade; - - -/** - * Created by IntelliJ IDEA. - * User: Gail - * Date: Jan 2, 2007 - * Time: 4:52:10 PM - * To change this template use File | Settings | File Templates. - */ -public class DeleteOrphanChild { - private Long id; - private Parent parent; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Parent getParent() { - return parent; - } - - public void setParent(Parent parent) { - this.parent = parent; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/G.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/G.java deleted file mode 100755 index 0f9d3f7baa..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/G.java +++ /dev/null @@ -1,95 +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 . - */ - -//$Id: $ - - -package org.hibernate.test.cascade; -import java.util.HashSet; -import java.util.Set; - -public class G -{ - // Constants ----------------------------------------------------------------------------------- - - // Static -------------------------------------------------------------------------------------- - - // Attributes ---------------------------------------------------------------------------------- - - private long id; - - private String data; - - // A 1 <-> 1 G - private A a; - - // G * <-> * H - private Set hs; - - // Constructors -------------------------------------------------------------------------------- - - public G() - { - this(null); - } - - public G(String data) - { - this.data = data; - hs = new HashSet(); - } - - // Public -------------------------------------------------------------------------------------- - - public String getData() - { - return data; - } - - public void setData(String data) - { - this.data = data; - } - - public A getA() - { - return a; - } - - public void setA(A a) - { - this.a = a; - } - - public Set getHs() - { - return hs; - } - - public void setHs(Set s) - { - hs = s; - } - - // Package protected --------------------------------------------------------------------------- - - long getId() - { - return id; - } - - // Protected ----------------------------------------------------------------------------------- - - // Private ------------------------------------------------------------------------------------- - - private void setId(long id) - { - this.id = id; - } - - // Inner classes ------------------------------------------------------------------------------- -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/H.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/H.java deleted file mode 100755 index 597333e4ff..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/H.java +++ /dev/null @@ -1,94 +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 . - */ - -//$Id: $ - - -package org.hibernate.test.cascade; -import java.util.HashSet; -import java.util.Set; - -public class H -{ - // Constants ----------------------------------------------------------------------------------- - - // Static -------------------------------------------------------------------------------------- - - // Attributes ---------------------------------------------------------------------------------- - - private long id; - - private String data; - - private A a; - - // G * <-> * H - private Set gs; - - // Constructors -------------------------------------------------------------------------------- - - public H() - { - this(null); - } - - public H(String data) - { - this.data = data; - gs = new HashSet(); - } - - // Public -------------------------------------------------------------------------------------- - - public long getId() - { - return id; - } - - public String getData() - { - return data; - } - - public void setData(String data) - { - this.data = data; - } - - public A getA() - { - return a; - } - - public void setA(A a) - { - this.a = a; - } - - public Set getGs() - { - return gs; - } - - public void setGs(Set gs) - { - this.gs = gs; - } - - // Package protected --------------------------------------------------------------------------- - - // Protected ----------------------------------------------------------------------------------- - - // Private ------------------------------------------------------------------------------------- - - private void setId(long id) - { - this.id = id; - } - - // Inner classes ------------------------------------------------------------------------------- -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.hbm.xml deleted file mode 100644 index 1549d77f2b..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.hbm.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.java deleted file mode 100644 index 4cf3af6fb3..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Job.java +++ /dev/null @@ -1,61 +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 . - */ - -// $Id: Job.java 6663 2005-05-03 20:55:31Z steveebersole $ -package org.hibernate.test.cascade; - - -/** - * Implementation of Job. - * - * @author Steve Ebersole - */ -public class Job { - private Long id; - private JobBatch batch; - private String processingInstructions; - private int status; - - /** GCLIB constructor */ - Job() {} - - protected Job(JobBatch batch) { - this.batch = batch; - } - - public Long getId() { - return id; - } - - /*package*/ void setId(Long id) { - this.id = id; - } - - public JobBatch getBatch() { - return batch; - } - - /*package*/ void setBatch(JobBatch batch) { - this.batch = batch; - } - - public String getProcessingInstructions() { - return processingInstructions; - } - - public void setProcessingInstructions(String processingInstructions) { - this.processingInstructions = processingInstructions; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.hbm.xml deleted file mode 100644 index 2301b533fe..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.hbm.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.java deleted file mode 100644 index db683e5a6a..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/JobBatch.java +++ /dev/null @@ -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 . - */ - -// $Id: JobBatch.java 6663 2005-05-03 20:55:31Z steveebersole $ -package org.hibernate.test.cascade; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -/** - * Implementation of JobBatch. - * - * @author Steve Ebersole - */ -public class JobBatch { - private Long id; - private Date batchDate; - private Set jobs = new HashSet(); - - /** CGLIB constructor */ - JobBatch() {} - - public JobBatch(Date batchDate) { - this.batchDate = batchDate; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Date getBatchDate() { - return batchDate; - } - - public void setBatchDate(Date batchDate) { - this.batchDate = batchDate; - } - - public Set getJobs() { - return jobs; - } - - public void setJobs(Set jobs) { - this.jobs = jobs; - } - - public Job createJob() { - Job job = new Job( this ); - jobs.add( job ); - return job; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/MultiPathCascade.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/MultiPathCascade.hbm.xml deleted file mode 100644 index 79f2b18f31..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/MultiPathCascade.hbm.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.hbm.xml deleted file mode 100644 index b25aaacd90..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.hbm.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.java b/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.java deleted file mode 100644 index 75dab92d19..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/Parent.java +++ /dev/null @@ -1,45 +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 . - */ -package org.hibernate.test.cascade; -import java.util.Set; - -/** - * Created by IntelliJ IDEA. - * User: Gail - * Date: Jan 2, 2007 - * Time: 4:50:24 PM - * To change this template use File | Settings | File Templates. - */ -public class Parent { - private Long id; - private Set deleteOrphanChildren; - private Set children; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Set getDeleteOrphanChildren() { - return deleteOrphanChildren; - } - - public void setDeleteOrphanChildren(Set deleteOrphanChildren) { - this.deleteOrphanChildren = deleteOrphanChildren; - } - - public Set getChildren() { - return children; - } - - public void setChildren(Set children) { - this.children = children; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/cascade/ParentWithAssignedId.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/cascade/ParentWithAssignedId.hbm.xml deleted file mode 100644 index 65eaa5f424..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/cascade/ParentWithAssignedId.hbm.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - -