Skip to content

Commit

Permalink
HHH-14329 Amend existing DirtyTrackingTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Nov 17, 2020
1 parent 2669848 commit da8706e
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ public void test() {
EnhancerTestUtils.checkDirtyTracking( entity, "someStrings" );
EnhancerTestUtils.clearDirtyTracking( entity );

// Association: this should not set the entity to dirty
Set<Integer> intSet = new HashSet<>();
intSet.add( 42 );
entity.someInts = intSet;
// Association, 1: creating the association will mark it dirty
Set<OtherEntity> associatedSet = new HashSet<>();
OtherEntity o = new OtherEntity();
o.id = 1l;
o.name = "other";
associatedSet.add( o );
entity.someAssociation = associatedSet;
EnhancerTestUtils.checkDirtyTracking( entity, "someAssociation" );
EnhancerTestUtils.clearDirtyTracking( entity );

// Association, 2: modifying a related entity should not
o.name = "newName";
EnhancerTestUtils.checkDirtyTracking( entity );
EnhancerTestUtils.checkDirtyTracking( o, "name" );

// testing composite object
Address address = new Address();
Expand Down Expand Up @@ -125,7 +134,7 @@ private static class SimpleEntity {
List<String> someStrings;

@OneToMany
Set<Integer> someInts;
Set<OtherEntity> someAssociation;

@Embedded
Address address;
Expand All @@ -141,4 +150,11 @@ public void setSomeNumber(Long someNumber) {
this.someNumber = someNumber;
}
}

@Entity
private static class OtherEntity {
@Id
Long id;
String name;
}
}

0 comments on commit da8706e

Please sign in to comment.