@@ -202,16 +202,21 @@ protected Object findProxied(HibernateProxy proxy)
202
202
return init .getImplementation ();
203
203
}
204
204
205
- // Alas, hibernate offers no public api to access this information, so we must resort to ugly hacks ...
205
+ /**
206
+ * Inspects a Hibernate proxy to try and determine the name of the identifier property
207
+ * (Hibernate proxies know the getter of the identifier property because it receives special
208
+ * treatment in the invocation handler). Alas, the field storing the method reference is
209
+ * private and has no getter, so we must resort to ugly reflection hacks to read its value ...
210
+ */
206
211
protected static class ProxyReader {
207
212
208
213
// static final so the JVM can inline the lookup
209
- private static final Field getIdentifierMethod ;
214
+ private static final Field getIdentifierMethodField ;
210
215
211
216
static {
212
217
try {
213
- getIdentifierMethod = BasicLazyInitializer .class .getDeclaredField ("getIdentifierMethod" );
214
- getIdentifierMethod .setAccessible (true );
218
+ getIdentifierMethodField = BasicLazyInitializer .class .getDeclaredField ("getIdentifierMethod" );
219
+ getIdentifierMethodField .setAccessible (true );
215
220
} catch (Exception e ) {
216
221
// should never happen: the field exists in all versions of hibernate 4 and 5
217
222
throw new RuntimeException (e );
@@ -223,7 +228,7 @@ protected static class ProxyReader {
223
228
*/
224
229
static String getIdentifierPropertyName (LazyInitializer init ) {
225
230
try {
226
- Method idGetter = (Method ) getIdentifierMethod .get (init );
231
+ Method idGetter = (Method ) getIdentifierMethodField .get (init );
227
232
if (idGetter == null ) {
228
233
return null ;
229
234
}
0 commit comments