@@ -63,11 +63,20 @@ public void test() {
6363 EnhancerTestUtils .checkDirtyTracking ( entity , "someStrings" );
6464 EnhancerTestUtils .clearDirtyTracking ( entity );
6565
66- // Association: this should not set the entity to dirty
67- Set <Integer > intSet = new HashSet <>();
68- intSet .add ( 42 );
69- entity .someInts = intSet ;
66+ // Association, 1: creating the association will mark it dirty
67+ Set <OtherEntity > associatedSet = new HashSet <>();
68+ OtherEntity o = new OtherEntity ();
69+ o .id = 1l ;
70+ o .name = "other" ;
71+ associatedSet .add ( o );
72+ entity .someAssociation = associatedSet ;
73+ EnhancerTestUtils .checkDirtyTracking ( entity , "someAssociation" );
74+ EnhancerTestUtils .clearDirtyTracking ( entity );
75+
76+ // Association, 2: modifying a related entity should not
77+ o .name = "newName" ;
7078 EnhancerTestUtils .checkDirtyTracking ( entity );
79+ EnhancerTestUtils .checkDirtyTracking ( o , "name" );
7180
7281 // testing composite object
7382 Address address = new Address ();
@@ -125,7 +134,7 @@ private static class SimpleEntity {
125134 List <String > someStrings ;
126135
127136 @ OneToMany
128- Set <Integer > someInts ;
137+ Set <OtherEntity > someAssociation ;
129138
130139 @ Embedded
131140 Address address ;
@@ -141,4 +150,11 @@ public void setSomeNumber(Long someNumber) {
141150 this .someNumber = someNumber ;
142151 }
143152 }
153+
154+ @ Entity
155+ private static class OtherEntity {
156+ @ Id
157+ Long id ;
158+ String name ;
159+ }
144160}
0 commit comments