1

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?

Harry Joy
  • 55,133
  • 29
  • 149
  • 204

2 Answers2

1

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()).

Community
  • 1
  • 1
waxwing
  • 17,792
  • 8
  • 61
  • 81
0

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.

Peter Svensson
  • 5,941
  • 1
  • 29
  • 31