Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate 5.0.11 DefaultCacheKeysFactory - NoSuchMethodError #114

Open
losingsleeep opened this issue Mar 8, 2018 · 3 comments
Open

Hibernate 5.0.11 DefaultCacheKeysFactory - NoSuchMethodError #114

losingsleeep opened this issue Mar 8, 2018 · 3 comments

Comments

@losingsleeep
Copy link

losingsleeep commented Mar 8, 2018

When using some versions of Spring Boot which are using Hibernate 5.0.11 by default, and specify org.hibernate.cache.redis.hibernate5.SingletonRedisRegionFactory in application properties, this run time error occurs when working with entities:
java.lang.NoSuchMethodError: org.hibernate.cache.internal.DefaultCacheKeysFactory.staticCreateEntityKey(Ljava/lang/Object;Lorg/hibernate/persister/entity/EntityPersister;Lorg/hibernate/engine/spi/SessionFactoryImplementor;Ljava/lang/String;)Ljava/lang/Object; at org.hibernate.cache.redis.hibernate5.strategy.ReadWriteRedisEntityRegionAccessStrategy.generateCacheKey(ReadWriteRedisEntityRegionAccessStrategy.java:54) ~[hibernate-redis-2.4.0.jar:na] at org.hibernate.event.internal.DefaultLoadEventListener.getFromSharedCache(DefaultLoadEventListener.java:644) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:595) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:462) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1129) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.access$2600(SessionImpl.java:164) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2696) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.get(SessionImpl.java:980) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:290) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:69) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:840) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:822) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:827) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:1161) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]

If hibernate version is explicitly specified to 5.0.12 in application POM file, the problem is fixed. But It's good to be able to use this project when using Hibernate 5.0.11 for any reason.

Technical explanation:
Classes inside hibernate5 package use Hibernate's class DefaultCacheKeysFactory to create cache key, but this class in version 5.0.11 is different from 5.0.12 and above. In 5.0.11 it does not have static methods which are used in this project source code.

I've changed the source code to fix it somehow, and created a pull request. Hope this helps.

Thanks to all guys starting this project and participating.

@losingsleeep losingsleeep changed the title Hibernate 5.0.11 DefaultCacheKeysFactory Hibernate 5.0.11 DefaultCacheKeysFactory - NoSuchMethodError Mar 8, 2018
@marcusleandro
Copy link

I am facing the same problem with hibernate version 5.0.2.Final

@losingsleeep
Copy link
Author

My pull request to fix this issue was accepted. Please check which version you're using.

@losingsleeep
Copy link
Author

Here's the commit in which pull request #113 was merged:

6914b15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants