Remove use of session#save, session#saveOrUpdate , session#update and session#remove from tests
This commit is contained in:
parent
34d6715815
commit
5699ed9b40
|
@ -13,7 +13,6 @@ public class EntityB extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "b")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
@ -23,7 +22,6 @@ public class EntityB extends AbstractEntity {
|
|||
@jakarta.persistence.ManyToOne(optional = false)
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
@ -32,7 +30,6 @@ public class EntityB extends AbstractEntity {
|
|||
@jakarta.persistence.ManyToOne(optional = false)
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -21,7 +21,6 @@ public class EntityC extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "c")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -25,7 +25,6 @@ public class EntityD extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "d")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -19,7 +19,6 @@ public class EntityF extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "f")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -13,7 +13,6 @@ public class B extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "b")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
@ -23,7 +22,6 @@ public class B extends AbstractEntity {
|
|||
@jakarta.persistence.ManyToOne(optional = false)
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
@ -32,7 +30,6 @@ public class B extends AbstractEntity {
|
|||
@jakarta.persistence.ManyToOne(optional = false)
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -21,7 +21,6 @@ public class C extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "c")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -25,7 +25,6 @@ public class D extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "d")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -19,7 +19,6 @@ public class F extends AbstractEntity {
|
|||
@jakarta.persistence.OneToMany(mappedBy = "f")
|
||||
@org.hibernate.annotations.Cascade({
|
||||
org.hibernate.annotations.CascadeType.PERSIST,
|
||||
org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.REFRESH
|
||||
})
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Dependent {
|
|||
|
||||
@Id
|
||||
@ManyToOne( cascade = CascadeType.PERSIST )
|
||||
@Cascade( org.hibernate.annotations.CascadeType.SAVE_UPDATE )
|
||||
@Cascade( {org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE} )
|
||||
@JoinColumn(nullable=false)
|
||||
public Employee getEmp() {
|
||||
return emp;
|
||||
|
|
|
@ -80,7 +80,7 @@ public class Employee implements Serializable {
|
|||
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
|
||||
mappedBy = "employees"
|
||||
)
|
||||
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
|
||||
@Cascade({org.hibernate.annotations.CascadeType.MERGE,
|
||||
org.hibernate.annotations.CascadeType.PERSIST})
|
||||
public Collection<Employer> getEmployers() {
|
||||
return employers;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class Employer implements Serializable {
|
|||
joinColumns = {@JoinColumn(name = "EMPLOYER_ID")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "CONTRACTOR_ID")}
|
||||
)
|
||||
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
|
||||
@Cascade({org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE})
|
||||
@OrderBy("name desc")
|
||||
public List getContractors() {
|
||||
return contractors;
|
||||
|
@ -63,7 +63,7 @@ public class Employer implements Serializable {
|
|||
joinColumns = {@JoinColumn(name = "EMPER_ID")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "EMPEE_ID")}
|
||||
)
|
||||
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
|
||||
@Cascade({org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.MERGE})
|
||||
@OrderBy("name asc")
|
||||
public Collection getEmployees() {
|
||||
return employees;
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.hibernate.orm.test.annotations.selectbeforeupdate;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
import org.hibernate.annotations.SelectBeforeUpdate;
|
||||
import org.hibernate.orm.test.legacy.Child;
|
||||
|
||||
|
@ -21,7 +22,6 @@ import jakarta.persistence.ManyToOne;
|
|||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
import static org.hibernate.annotations.CascadeType.SAVE_UPDATE;
|
||||
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
|
@ -51,7 +51,7 @@ public class SelectBeforeUpdateWithCascadeTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
ParentEntity parent1 = new ParentEntity();
|
||||
parent1.setChildEntity( childEntity );
|
||||
parent1.setChildEntity( session.merge( childEntity ) );
|
||||
|
||||
session.persist( parent1 );
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class SelectBeforeUpdateWithCascadeTest {
|
|||
scope.inTransaction(
|
||||
session -> {
|
||||
ParentEntity parent2 = new ParentEntity();
|
||||
parent2.setChildEntity( childEntity );
|
||||
parent2.setChildEntity( session.merge( childEntity ) );
|
||||
|
||||
session.persist( parent2 );
|
||||
}
|
||||
|
@ -181,12 +181,10 @@ public class SelectBeforeUpdateWithCascadeTest {
|
|||
private Long id;
|
||||
|
||||
@ManyToOne
|
||||
@Cascade(SAVE_UPDATE)
|
||||
@Cascade({ CascadeType.MERGE, CascadeType.PERSIST})
|
||||
@JoinColumn(name = "child_entity_id")
|
||||
private ChildEntity childEntity;
|
||||
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.hibernate.testing.orm.junit.Setting;
|
|||
* | <- -> |
|
||||
* -- (1 : N) -- (delivery) --
|
||||
* <p>
|
||||
* Arrows indicate the direction of cascade-merge, cascade-save, and cascade-save-or-update
|
||||
* Arrows indicate the direction of cascade-merge, cascade-persist
|
||||
* <p>
|
||||
* It reproduced the following issues:
|
||||
* http://opensource.atlassian.com/projects/hibernate/browse/HHH-3046
|
||||
|
|
|
@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
* | <- -> |
|
||||
* -- (1 : N) -- (delivery) --
|
||||
* <p>
|
||||
* Arrows indicate the direction of cascade-merge, cascade-save, cascade-refresh and cascade-save-or-update
|
||||
* Arrows indicate the direction of cascade-merge, cascade-persist, cascade-refresh
|
||||
* <p>
|
||||
* It reproduces the following issues:
|
||||
* https://hibernate.atlassian.net/browse/HHH-9512
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.hibernate.testing.orm.junit.Setting;
|
|||
* | <- -> |
|
||||
* -- (1 : N) -- (delivery) --
|
||||
* <p>
|
||||
* Arrows indicate the direction of cascade-merge, cascade-save, and cascade-save-or-update
|
||||
* Arrows indicate the direction of cascade-merge, cascade-persist
|
||||
* <p>
|
||||
* It reproduced the following issues:
|
||||
* http://opensource.atlassian.com/projects/hibernate/browse/HHH-3046
|
||||
|
|
|
@ -19,10 +19,11 @@ import jakarta.persistence.ManyToOne;
|
|||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.collection.spi.AbstractPersistentCollection;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -85,7 +86,7 @@ public class BagDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey( "HHH-5855")
|
||||
public void testSimpleAddDetached(SessionFactoryScope scope) {
|
||||
// Create 2 detached Child objects.
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -104,6 +105,7 @@ public class BagDelayedOperationTest {
|
|||
Parent p = session.get( Parent.class, parentId );
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
// add detached Child c
|
||||
session.lock( c1, LockOptions.NONE );
|
||||
p.addChild( c1 );
|
||||
// collection should still be uninitialized
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
|
@ -140,7 +142,7 @@ public class BagDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleAddTransient(SessionFactoryScope scope) {
|
||||
// Add a transient Child and commit.
|
||||
scope.inTransaction(
|
||||
|
@ -185,7 +187,7 @@ public class BagDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleAddManaged(SessionFactoryScope scope) {
|
||||
// Add 2 Child entities
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -240,7 +242,7 @@ public class BagDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-11209")
|
||||
@JiraKey("HHH-11209")
|
||||
public void testMergeInitializedBagAndRemerge(SessionFactoryScope scope) {
|
||||
Parent parent = scope.fromTransaction(
|
||||
session -> {
|
||||
|
@ -255,7 +257,7 @@ public class BagDelayedOperationTest {
|
|||
|
||||
Parent modifiedParent = scope.fromTransaction(
|
||||
session -> {
|
||||
Parent p = (Parent) session.merge( parent );
|
||||
Parent p = session.merge( parent );
|
||||
assertTrue( Hibernate.isInitialized( p.getChildren() ) );
|
||||
Child c = new Child( "Zeke" );
|
||||
c.setParent( p );
|
||||
|
@ -269,7 +271,7 @@ public class BagDelayedOperationTest {
|
|||
// Merge detached Parent with initialized children
|
||||
Parent mergedParent = scope.fromTransaction(
|
||||
session -> {
|
||||
Parent p = (Parent) session.merge( modifiedParent );
|
||||
Parent p = session.merge( modifiedParent );
|
||||
// after merging, p#children will be initialized
|
||||
assertTrue( Hibernate.isInitialized( p.getChildren() ) );
|
||||
assertFalse( ( (AbstractPersistentCollection) p.getChildren() ).hasQueuedOperations() );
|
||||
|
@ -280,7 +282,7 @@ public class BagDelayedOperationTest {
|
|||
// Merge detached Parent
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Parent p = (Parent) session.merge( mergedParent );
|
||||
Parent p = session.merge( mergedParent );
|
||||
assertTrue( Hibernate.isInitialized( p.getChildren() ) );
|
||||
assertFalse( ( (AbstractPersistentCollection) p.getChildren() ).hasQueuedOperations() );
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.hibernate.Hibernate;
|
|||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -92,7 +92,7 @@ public class ListDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey( "HHH-5855")
|
||||
public void testSimpleAddDetached(SessionFactoryScope scope) {
|
||||
// Create 2 detached Child objects.
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -111,7 +111,7 @@ public class ListDelayedOperationTest {
|
|||
Parent p = session.get( Parent.class, parentId );
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
// add detached Child c
|
||||
p.addChild( c1 );
|
||||
p.addChild( session.merge( c1 ) );
|
||||
// collection should still be uninitialized
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class ListDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey( "HHH-5855")
|
||||
public void testSimpleAddTransient(SessionFactoryScope scope) {
|
||||
// Add a transient Child and commit.
|
||||
scope.inTransaction(
|
||||
|
@ -195,7 +195,7 @@ public class ListDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey( "HHH-5855")
|
||||
public void testSimpleAddManaged(SessionFactoryScope scope) {
|
||||
// Add 2 Child entities
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -251,7 +251,7 @@ public class ListDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey( "HHH-5855")
|
||||
public void testSimpleRemoveDetached(SessionFactoryScope scope) {
|
||||
// Get the 2 Child entities and detach.
|
||||
Child c1 = scope.fromTransaction(
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.hibernate.Hibernate;
|
|||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
@ -88,7 +88,7 @@ public class SetDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleAddDetached(SessionFactoryScope scope) {
|
||||
// Create 2 detached Child objects.
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -107,7 +107,7 @@ public class SetDelayedOperationTest {
|
|||
Parent p = session.get( Parent.class, parentId );
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
// add detached Child c
|
||||
p.addChild( c1 );
|
||||
p.addChild( session.merge( c1 ) );
|
||||
// collection should still be uninitialized
|
||||
assertFalse( Hibernate.isInitialized( p.getChildren() ) );
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class SetDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleAddTransient(SessionFactoryScope scope) {
|
||||
// Add a transient Child and commit.
|
||||
scope.inTransaction(
|
||||
|
@ -190,7 +190,7 @@ public class SetDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleAddManaged(SessionFactoryScope scope) {
|
||||
// Add 2 Child entities
|
||||
Child c1 = new Child( "Darwin" );
|
||||
|
@ -245,7 +245,7 @@ public class SetDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleRemoveDetached(SessionFactoryScope scope) {
|
||||
// Get the 2 Child entities and detach.
|
||||
Child c1 = scope.fromTransaction(
|
||||
|
@ -302,7 +302,7 @@ public class SetDelayedOperationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-5855")
|
||||
@JiraKey("HHH-5855")
|
||||
public void testSimpleRemoveManaged(SessionFactoryScope scope) {
|
||||
// Remove a managed entity element and commit
|
||||
scope.inTransaction(
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.FailureExpected;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -48,14 +48,14 @@ public class ExtraLazyTest {
|
|||
public void tearDown(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
session.createQuery( "delete from Document" ).executeUpdate();
|
||||
session.createQuery( "delete from User" ).executeUpdate();
|
||||
session.createQuery( "delete from Child" ).executeUpdate();
|
||||
session.createQuery( "delete from Parent" ).executeUpdate();
|
||||
session.createQuery( "delete from Student" ).executeUpdate();
|
||||
session.createQuery( "delete from School" ).executeUpdate();
|
||||
session.createQuery( "delete from Championship" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Group" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Document" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from User" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Child" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Parent" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Student" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from School" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Championship" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class ExtraLazyTest {
|
|||
assertThat( g.getUsers().size(), is( 1 ) );
|
||||
Map smap = ( (User) g.getUsers().get( "gavin" ) ).getSession();
|
||||
assertThat( smap.size(), is( 1 ) );
|
||||
User gavin = (User) g.getUsers().put( "gavin", user2 );
|
||||
User gavin = (User) g.getUsers().put( "gavin", session.merge( user2 ) );
|
||||
session.remove( gavin );
|
||||
assertThat(
|
||||
session.createQuery( "select count(*) from SessionAttribute" ).uniqueResult(),
|
||||
|
@ -296,14 +296,14 @@ public class ExtraLazyTest {
|
|||
gavin = (User) results.get( 0 );
|
||||
assertThat( gavin.getName(), is( "gavin" ) );
|
||||
assertThat( gavin.getSession().size(), is( 2 ) );
|
||||
session.createQuery( "delete SessionAttribute" ).executeUpdate();
|
||||
session.createQuery( "delete User" ).executeUpdate();
|
||||
session.createMutationQuery( "delete SessionAttribute" ).executeUpdate();
|
||||
session.createMutationQuery( "delete User" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-4294")
|
||||
@JiraKey("HHH-4294")
|
||||
public void testMap(SessionFactoryScope scope) {
|
||||
Parent parent = new Parent();
|
||||
Child child = new Child();
|
||||
|
@ -329,7 +329,7 @@ public class ExtraLazyTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10874")
|
||||
@JiraKey("HHH-10874")
|
||||
public void testWhereClauseOnBidirectionalCollection(SessionFactoryScope scope) {
|
||||
School school = new School( 1 );
|
||||
Student gavin = new Student( "gavin", 4 );
|
||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.orm.test.map;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -30,8 +32,8 @@ public class MapIndexFormulaTest {
|
|||
public void tearDown(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
session.createQuery( "delete from Group" ).executeUpdate();
|
||||
session.createQuery( "delete from User" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from Group" ).executeUpdate();
|
||||
session.createMutationQuery( "delete from User" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -88,6 +90,7 @@ public class MapIndexFormulaTest {
|
|||
assertEquals( 1, g.getUsers().size() );
|
||||
Map smap = ( (User) g.getUsers().get( "gavin" ) ).getSession();
|
||||
assertEquals( 1, smap.size() );
|
||||
session.lock( turin , LockMode.NONE);
|
||||
User gavin = (User) g.getUsers().put( "gavin", turin );
|
||||
session.remove( gavin );
|
||||
assertEquals(
|
||||
|
@ -141,8 +144,8 @@ public class MapIndexFormulaTest {
|
|||
gavin = (User) results.get( 0 );
|
||||
assertEquals( "gavin", gavin.getName() );
|
||||
assertEquals( 2, gavin.getSession().size() );
|
||||
session.createQuery( "delete SessionAttribute" ).executeUpdate();
|
||||
session.createQuery( "delete User" ).executeUpdate();
|
||||
session.createMutationQuery( "delete SessionAttribute" ).executeUpdate();
|
||||
session.createMutationQuery( "delete User" ).executeUpdate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
<many-to-one name="mailingAddress"
|
||||
class="Address"
|
||||
cascade="persist,save-update,delete"
|
||||
cascade="persist,merge,delete"
|
||||
fetch="join">
|
||||
<column name="mailing_address_fk"/>
|
||||
<formula>'MAILING'</formula>
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
<many-to-one name="shippingAddress"
|
||||
class="Address"
|
||||
cascade="persist,save-update,delete"
|
||||
cascade="persist,merge,delete"
|
||||
fetch="join">
|
||||
<column name="shipping_address_fk"/>
|
||||
<formula>'SHIPPING'</formula>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<generator class="native" />
|
||||
</id>
|
||||
<property name="data" />
|
||||
<many-to-one name="reference" cascade="save-update"
|
||||
<many-to-one name="reference" cascade="merge,persist"
|
||||
class="BidirectionalEagerHbmRefEdPK" column="BIDIRECTIONAL_REFERENCED_ID" />
|
||||
</class>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<generator class="native"/>
|
||||
</id>
|
||||
|
||||
<many-to-one name="person" class="org.hibernate.orm.test.jcache.domain.Person" cascade="save-update,lock"
|
||||
<many-to-one name="person" class="org.hibernate.orm.test.jcache.domain.Person" cascade="merge,persist,lock"
|
||||
column="person_id"
|
||||
unique="true"
|
||||
not-null="true"/>
|
||||
|
|
Loading…
Reference in New Issue