-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate OGM retrieve from ENTITIES CACHE
PostPosted: Thu Aug 01, 2013 7:44 pm 
Newbie

Joined: Thu Aug 01, 2013 7:33 pm
Posts: 2
Is there a way to retrieve data (or dump it all) from the ENTITIES cache that was filled by a Hibernate OGM persist?

For example, as you can see, the below prints out 0 for the cache size, but I would think it should be at least one, since Hibernate OGM successfully entered a value


EntityManager em = emf.createEntityManager();
Breed collie3 = new Breed();
collie3.setName( "Sammyx" );
em.persist( collie3 );
Dog dina = new Dog();
dina.setName( "Dinax" );
dina.setBreed( collie3 );

em.persist( dina );
Long dinaId = dina.getId();
em.flush();
em.close();
tm.commit();
CacheManager manager = new DefaultCacheManager();
System.out.println("--> " + manager.getCacheNames());
Cache localCache = manager.getCache("ENTITIES(dist_sync)");
System.out.println("local cache = " + localCache.size());

RESULTS:

About to store dog and breed
local cache = 0
Found dog Dinax of breed Sammyx


Top
 Profile  
 
 Post subject: Re: Hibernate OGM retrieve from ENTITIES CACHE
PostPosted: Fri Aug 02, 2013 4:30 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi, I'm assuming that's an Infinispan CacheManager?

There are several things to consider:

- When Infinispan is configured with DIST_SYNC the size() operator is not accurate, it will only show the size of the local node, not the whole content of the data grid.

- you're creating a new CacheManager, not taking the instance which OGM is using. That could work as long as this CacheManager connects to the other one, but you're effectively needing to rebalance the cluster: rebalancing is automatic but happens in the background, it likely didn't even finish connecting if you don't give it some wait time.

- the cachename must match exactly - not sure if that cache name is the one you've configured OGM to use?

It would be easier to extract the reference of the Infinispan cache from the emf.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.