10
10
import java .util .Map ;
11
11
12
12
import org .hibernate .bytecode .instrumentation .spi .LazyPropertyInitializer ;
13
+ import org .hibernate .engine .spi .CompositeOwner ;
14
+ import org .hibernate .engine .spi .CompositeTracker ;
13
15
import org .hibernate .engine .spi .SessionImplementor ;
14
16
import org .hibernate .property .access .internal .PropertyAccessStrategyBackRefImpl ;
15
17
import org .hibernate .tuple .NonIdentifierAttribute ;
@@ -147,6 +149,7 @@ else if ( row[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY || row[i] == Prop
147
149
public static Object [] replace (
148
150
final Object [] original ,
149
151
final Object [] target ,
152
+ final String [] names ,
150
153
final Type [] types ,
151
154
final SessionImplementor session ,
152
155
final Object owner ,
@@ -176,6 +179,11 @@ else if ( target[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
176
179
else {
177
180
copied [i ] = types [i ].replace ( original [i ], target [i ], session , owner , copyCache );
178
181
}
182
+
183
+ // for bytecode enhanced entities, set the composite tracking structure
184
+ if ( copied [i ] instanceof CompositeTracker && owner instanceof CompositeOwner ) {
185
+ ( (CompositeTracker ) copied [i ] ).$$_hibernate_setOwner ( names [i ], (CompositeOwner ) owner );
186
+ }
179
187
}
180
188
return copied ;
181
189
}
@@ -196,6 +204,7 @@ else if ( target[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
196
204
public static Object [] replace (
197
205
final Object [] original ,
198
206
final Object [] target ,
207
+ final String [] names ,
199
208
final Type [] types ,
200
209
final SessionImplementor session ,
201
210
final Object owner ,
@@ -204,12 +213,17 @@ public static Object[] replace(
204
213
Object [] copied = new Object [original .length ];
205
214
for ( int i = 0 ; i < types .length ; i ++ ) {
206
215
if ( original [i ] == LazyPropertyInitializer .UNFETCHED_PROPERTY
207
- || original [i ] == PropertyAccessStrategyBackRefImpl .UNKNOWN ) {
216
+ || original [i ] == PropertyAccessStrategyBackRefImpl .UNKNOWN ) {
208
217
copied [i ] = target [i ];
209
218
}
210
219
else {
211
220
copied [i ] = types [i ].replace ( original [i ], target [i ], session , owner , copyCache , foreignKeyDirection );
212
221
}
222
+
223
+ // for bytecode enhanced entities, set the composite tracking structure
224
+ if ( copied [i ] instanceof CompositeTracker && owner instanceof CompositeOwner ) {
225
+ ( (CompositeTracker ) copied [i ] ).$$_hibernate_setOwner ( names [i ], (CompositeOwner ) owner );
226
+ }
213
227
}
214
228
return copied ;
215
229
}
0 commit comments