Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to print the objects that are stored in the isolated cache in EclipseLink?
How to print the objects that are stored in the isolated cache in EclipseLink? [message #994951] Fri, 28 December 2012 18:05 Go to next message
Alfredo Osorio is currently offline Alfredo OsorioFriend
Messages: 6
Registered: March 2012
Junior Member
I want to see what objects are stored in the isolated cache (L1 cache) in EclipseLink. Is there an API that let me do that? I tried google but couldn't find anything.

If you are interested in the why it's because I have found that after loading some objects in the persistence context the queries slow for example a query that took 100 ms just at the start of the transaction now it's taking 200 ms if it is executed in the middle of the transaction after some other operations have already happened. If I do entityManager.clear() prior to the query execution the query once again takes 100 ms. I believe this happens because there are many objects loaded in the Persistence Context that affects EclipseLink performance. That's why I would like to verify what objects are in the persistence context.
Re: How to print the objects that are stored in the isolated cache in EclipseLink? [message #995049 is a reply to message #994951] Sat, 29 December 2012 00:18 Go to previous message
Alfredo Osorio is currently offline Alfredo OsorioFriend
Messages: 6
Registered: March 2012
Junior Member
After exploring the EclipseLink source code I found that the objects stored in the persistence context are located in a maps called identityMaps for each entity class there is a map which stores all the objects of that type.

You can print the contents of the map using the following methods:

public interface IdentityMapAccessor {
    /**
     * PUBLIC:
     * Used to print all the Objects in the identity map of the given Class type.
     * The output of this method will be logged to this session's SessionLog at SEVERE level.
     */
    public void printIdentityMap(Class theClass);

    /**
     * PUBLIC:
     * Used to print all the Objects in every identity map in this session.
     * The output of this method will be logged to this session's SessionLog at SEVERE level.
     */
    public void printIdentityMaps();
}


Examples:

((JpaEntityManager) entityManager.getDelegate())
            .getActiveSession()
            .getIdentityMapAccessor()
            .printIdentityMaps();
((JpaEntityManager) entityManager.getDelegate())
            .getActiveSession()
            .getIdentityMapAccessor()
            .printIdentityMap(MyClass.class);



Regards,
Alfredo Osorio
http://www.sonrisaseventos.com/

[Updated on: Fri, 07 November 2014 22:05]

Report message to a moderator

Previous Topic:browse eclipselink maven repository
Next Topic:Dynamic JPA problem - empty Metamodel
Goto Forum:
  


Current Time: Sat Apr 20 03:26:56 GMT 2024

Powered by FUDForum. Page generated in 0.02563 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top