开发者

Hibernate: 1st level cache

开发者 https://www.devze.com 2023-03-10 18:19 出处:网络
Could someone tell me how could I peek into objects being managed by a session in Hibernate? I am trying to use eclipse debugger and drill into persistenceContext but I am not sure if that is where I

Could someone tell me how could I peek into objects being managed by a session in Hibernate?

I am trying to use eclipse debugger and drill into persistenceContext but I am not sure if that is where I would f开发者_如何学JAVAind the objects being managed by hibernate session.

Could someone tell me how to find out the objects that are being managed by Hibernate objects?

Thanks.


Are you looking to use this information simply for your own benefit and learning? You won't be able to access the information as far as I know in any sort of standard JPA-approved method.

However, if you're using Hibernate, you could put a breakpoint and dig into Hibernate's implementation of PersistenceContext.java which is called StatefulPersistenceContext.java. There should be a map of entities and collections loaded. You will of course need the Hibernate source code for this.

The fields should be named something like...

private Map entitiesByKey;
private Map proxiesByKey;
private Map collectionsByKey;

EDIT: Don't forget to toggle "Show Logical Structures" in the Eclipse debugger or navigating those maps will drive you insane.

0

精彩评论

暂无评论...
验证码 换一张
取 消