0

I am using Hazelcast as 2L cache provider for hibernate. My problem is that im trying to use Portable serialization, but by default when Application works it uses CacheKeyImpl class from hazelcast.hibernate.region package for Key serialization. How to disable that way of serialization?

CacheKeyImpl contains private String entityOrRoleName; field, it stores full path to the Entity, and that is why I cant set Hazelcast cache to work properly for two different Applications (because in different projects that deals with the DB, the path to the Entity is different, so thats why Keys of the same entity has different values after serialization). Do someone face the similar problem? Thanks in advance.

  • I have discovered that I use the version of hazelcast-hibernate52 version 1.2, after setting this version in my pom file, to 1.2.3 everything became fine. Sorry for interapting – Женя Воробей Aug 10 '18 at 11:47
  • I had made mistake. After setting hazelcast-hibernate version on 1.2.3 only Key change its format, and now it looks like com.myproject.backoffice.entity.Currency#2 , but the problem remain the same. As Key contains full path, I cant to combine two platforms with different packages names, and the Custom serialization doesnt work, I dont know the reason why. – Женя Воробей Aug 10 '18 at 12:50
  • I don't know if Hazelcast integration supports the option, but with Infinispan 2LC provider you can set `hibernate.cache.keys_factory` to `simple` (instead of `default`) and then you'll use directly the `@Id` as keys in the cache. Check out https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/cfg/AvailableSettings.html#CACHE_KEYS_FACTORY – Radim Vansa Aug 13 '18 at 08:33
  • Btw. if you can make sure to use Hibernate 5.3 instead. Version 5.2 is not going to receive too much maintenance. – Radim Vansa Aug 13 '18 at 08:35
  • Radim, thanks for your answer, but for Hazelcast as provider Hibernate doesn`t supports hibernate.cache.keys_factory yet. And unfortunarely Hazelcast doesnt deal with Hibernate 3.x.x also. – Женя Воробей Aug 14 '18 at 14:56
  • I would say that it's rather fortunate. Hibernate 3.x is dead and gone. – Radim Vansa Aug 16 '18 at 14:12
  • Sorry for TYPO, hibernate 5.3 I meant. – Женя Воробей Aug 17 '18 at 12:23
  • Have you tried Infinispan as Hibernate second-level cache provider? It already supports Hibernate 5.3 (a simple tutorial can be found [here](https://github.com/infinispan/infinispan-simple-tutorials/tree/master/hibernate-cache/local), others are available [here](http://infinispan.org/tutorials/)). p.s. I'm an Infinispan developer ;) – Galder Zamarreño Aug 24 '18 at 09:26
  • Galder Zamarreño, thanks for advise, I have read about it, but I work on big project, and Hazelcast is deeply used in it, so I have to deal with it. – Женя Воробей Aug 29 '18 at 07:09

0 Answers0