Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

What does $$_Javasassist_11 means in java?

Writer Olivia Zamora

I'm using hibernate in java. I'm fetching list of object by running a query like from MyObject where field='name'. This runs successfully and when I do list.size() it also returns 1. But when I do list.get(0) I get a object with all fields null. In debug when I hover on object it displays like this: com.xyz.data.MyObect_$$_javasassit_11. What does this means?

2 Answers

This is a side-effect of how Hibernate implements lazy loading. com.xyz.data.MyObect_$$_javasassit_11 is a subclass created by Hibernate, that has overridden all methods to first make sure the entity is loaded and then forward the call tp the actual instance.

Usually this is transparent, but it can be important in some cases. One of the most common ones is the dreaded LazyInitializationException. If your debugger supports watch expressions, you can get the real values of the fields using the accessor methods (instead of looking at field x create an expression for myobject.getX()).

It's a proxy class created by Hibernate for you. This allows hibernate to (among other things) to cache data and lazy load instance variable data and so on.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy