From f9678c9715fc0d4552e75071b3d610ccf8930ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20B=C3=ADzik?= Date: Wed, 25 Mar 2020 06:31:57 +0100 Subject: [PATCH] HHH-13900: replaced all spaces by tabs, assigned jira key to test, removed todo to assign jira key to test --- .../internal/DefaultDeleteEventListener.java | 4 +- .../delete/keepreference/DeathStar.java | 18 +-- .../keepreference/KeepReferenceTest.java | 130 +++++++++--------- .../delete/keepreference/Universe.java | 16 +-- 4 files changed, 84 insertions(+), 84 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultDeleteEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultDeleteEventListener.java index a03442eeef..43ded6e14f 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultDeleteEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultDeleteEventListener.java @@ -281,8 +281,8 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback new ForeignKeys.Nullifier( entity, true, false, session, persister ).nullifyTransientReferences( entityEntry.getDeletedState() ); new Nullability( session ).checkNullability( entityEntry.getDeletedState(), persister, Nullability.NullabilityCheckType.DELETE ); - if( persister.getClassMetadata() != null && !persister.getClassMetadata().keepReference() ) { - persistenceContext.registerNullifiableEntityKey(key); + if ( persister.getClassMetadata() != null && !persister.getClassMetadata().keepReference() ) { + persistenceContext.registerNullifiableEntityKey( key ); } if ( isOrphanRemovalBeforeUpdates ) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/DeathStar.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/DeathStar.java index aa7bc03380..bb8e53620e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/DeathStar.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/DeathStar.java @@ -21,13 +21,13 @@ import java.util.Set; @Where(clause = "deleted = false") public class DeathStar extends BaseEntity { - @NotNull + @NotNull @OneToOne(optional = false, cascade = CascadeType.ALL, fetch = FetchType.EAGER) private Vader vader; @OneToMany(cascade = CascadeType.MERGE, orphanRemoval = true, mappedBy = "deathStar",fetch = FetchType.EAGER) private Set troppers; - @NotNull - @OneToOne(optional = false, fetch = FetchType.EAGER) + @NotNull + @OneToOne(optional = false, fetch = FetchType.EAGER) private Universe universe; public Vader getVader() { @@ -46,11 +46,11 @@ public class DeathStar extends BaseEntity { this.troppers = troppers; } - public Universe getUniverse() { - return universe; - } + public Universe getUniverse() { + return universe; + } - public void setUniverse(Universe universe) { - this.universe = universe; - } + public void setUniverse(Universe universe) { + this.universe = universe; + } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/KeepReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/KeepReferenceTest.java index abb906ae65..8ffd6802fe 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/KeepReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/KeepReferenceTest.java @@ -25,95 +25,95 @@ public class KeepReferenceTest extends BaseCoreFunctionalTestCase { @Test - @TestForIssue( jiraKey = "HHH-XXXXX")//TODO: assign jira key + @TestForIssue( jiraKey = "HHH-13900") public void keepReferenceShouldKeepReference(){ - Transaction transaction; + Transaction transaction; Session session = openSession(); - transaction = session.beginTransaction(); + transaction = session.beginTransaction(); - Universe universe = new Universe(); - session.save(universe); + Universe universe = new Universe(); + session.save(universe); - DeathStar deathStar = new DeathStar(); - deathStar.setUniverse(universe); - universe.setDeathStar(deathStar); + DeathStar deathStar = new DeathStar(); + deathStar.setUniverse(universe); + universe.setDeathStar(deathStar); - Vader vader = new Vader(); - vader.setDeathStar(deathStar); + Vader vader = new Vader(); + vader.setDeathStar(deathStar); - deathStar.setVader(vader); - session.save(deathStar); + deathStar.setVader(vader); + session.save(deathStar); - Trooper trooper = new Trooper(); - trooper.setCode("TK-421"); - trooper.setDeathStar(deathStar); - deathStar.setTroppers(Sets.newLinkedHashSet(trooper)); + Trooper trooper = new Trooper(); + trooper.setCode("TK-421"); + trooper.setDeathStar(deathStar); + deathStar.setTroppers(Sets.newLinkedHashSet(trooper)); - session.save(trooper); + session.save(trooper); - transaction.commit(); - session.clear(); + transaction.commit(); + session.clear(); - transaction = session.beginTransaction(); - deathStar = session.get(DeathStar.class, deathStar.getId()); - assertEquals(1, deathStar.getTroppers().size()); - assertNotNull(deathStar.getVader()); - transaction.commit(); - session.clear(); + transaction = session.beginTransaction(); + deathStar = session.get(DeathStar.class, deathStar.getId()); + assertEquals(1, deathStar.getTroppers().size()); + assertNotNull(deathStar.getVader()); + transaction.commit(); + session.clear(); - transaction = session.beginTransaction(); - session.delete(deathStar); - transaction.commit(); - session.clear(); + transaction = session.beginTransaction(); + session.delete(deathStar); + transaction.commit(); + session.clear(); - transaction = session.beginTransaction(); + transaction = session.beginTransaction(); - //universe should not be deleted - universe = session.get(Universe.class, universe.getId()); - assertNotNull(universe); - //deathStar should be deleted - deathStar = session.get(DeathStar.class, deathStar.getId()); - assertNull(deathStar); - List universes = session.createSQLQuery("SELECT * from universe").list(); - List deathStars = session.createSQLQuery("SELECT * from deathstar").list(); - List troopers = session.createSQLQuery("SELECT * from trooper").list(); - List vaders = session.createSQLQuery("SELECT * from vader").list(); + //universe should not be deleted + universe = session.get(Universe.class, universe.getId()); + assertNotNull(universe); + //deathStar should be deleted + deathStar = session.get(DeathStar.class, deathStar.getId()); + assertNull(deathStar); + List universes = session.createSQLQuery("SELECT * from universe").list(); + List deathStars = session.createSQLQuery("SELECT * from deathstar").list(); + List troopers = session.createSQLQuery("SELECT * from trooper").list(); + List vaders = session.createSQLQuery("SELECT * from vader").list(); - assertEquals(1, universes.size()); - assertEquals(1, deathStars.size()); - assertEquals(1, troopers.size()); - assertEquals(1, vaders.size()); + assertEquals(1, universes.size()); + assertEquals(1, deathStars.size()); + assertEquals(1, troopers.size()); + assertEquals(1, vaders.size()); - //check if deleted is set - assertTrue((Boolean)((Object[])deathStars.get(0))[1]); - assertTrue((Boolean)((Object[])troopers.get(0))[1]); - assertTrue((Boolean)((Object[])vaders.get(0))[1]); - //universe should not be delted - assertFalse((Boolean)((Object[])universes.get(0))[1]); + //check if deleted is set + assertTrue((Boolean)((Object[])deathStars.get(0))[1]); + assertTrue((Boolean)((Object[])troopers.get(0))[1]); + assertTrue((Boolean)((Object[])vaders.get(0))[1]); + //universe should not be delted + assertFalse((Boolean)((Object[])universes.get(0))[1]); - //check if references are kept - assertNotNull(((Object[])deathStars.get(0))[2]); - assertNotNull(((Object[])troopers.get(0))[3]); + //check if references are kept + assertNotNull(((Object[])deathStars.get(0))[2]); + assertNotNull(((Object[])troopers.get(0))[3]); - session.close(); + session.close(); - cleanupData(); + cleanupData(); } - private void cleanupData() { - doInHibernate( this::sessionFactory, s -> { - s.createSQLQuery("delete from trooper").executeUpdate(); - s.createSQLQuery("delete from deathstar").executeUpdate(); - s.createSQLQuery("delete from vader").executeUpdate(); - s.createSQLQuery("delete from universe").executeUpdate(); - }); - } + private void cleanupData() { + doInHibernate( this::sessionFactory, s -> { + s.createSQLQuery("delete from trooper").executeUpdate(); + s.createSQLQuery("delete from deathstar").executeUpdate(); + s.createSQLQuery("delete from vader").executeUpdate(); + s.createSQLQuery("delete from universe").executeUpdate(); + }); + } - @Override + @Override protected Class[] getAnnotatedClasses() { return new Class[] { BaseEntity.class, - Universe.class, + Universe.class, DeathStar.class, Vader.class, Trooper.class diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/Universe.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/Universe.java index 0dd02a92c9..4eb8dc2461 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/Universe.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/delete/keepreference/Universe.java @@ -12,14 +12,14 @@ import javax.persistence.OneToOne; @Where(clause = "deleted = false") public class Universe extends BaseEntity { - @OneToOne(optional = true, fetch = FetchType.EAGER, mappedBy = "universe") - DeathStar deathStar; + @OneToOne(optional = true, fetch = FetchType.EAGER, mappedBy = "universe") + DeathStar deathStar; - public DeathStar getDeathStar() { - return deathStar; - } + public DeathStar getDeathStar() { + return deathStar; + } - public void setDeathStar(DeathStar deathStar) { - this.deathStar = deathStar; - } + public void setDeathStar(DeathStar deathStar) { + this.deathStar = deathStar; + } }