@@ -63,11 +63,20 @@ public void test() {
63
63
EnhancerTestUtils .checkDirtyTracking ( entity , "someStrings" );
64
64
EnhancerTestUtils .clearDirtyTracking ( entity );
65
65
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" ;
70
78
EnhancerTestUtils .checkDirtyTracking ( entity );
79
+ EnhancerTestUtils .checkDirtyTracking ( o , "name" );
71
80
72
81
// testing composite object
73
82
Address address = new Address ();
@@ -125,7 +134,7 @@ private static class SimpleEntity {
125
134
List <String > someStrings ;
126
135
127
136
@ OneToMany
128
- Set <Integer > someInts ;
137
+ Set <OtherEntity > someAssociation ;
129
138
130
139
@ Embedded
131
140
Address address ;
@@ -141,4 +150,11 @@ public void setSomeNumber(Long someNumber) {
141
150
this .someNumber = someNumber ;
142
151
}
143
152
}
153
+
154
+ @ Entity
155
+ private static class OtherEntity {
156
+ @ Id
157
+ Long id ;
158
+ String name ;
159
+ }
144
160
}
0 commit comments