-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 cache layer 2 with Hazelcast doesn't work #11748
Comments
Hi @pascalgrimaud , |
@vudangngoc : thanks for sharing your project. It will help for reproducing your issue. Then about me, I don't have time to have a look at your problem. I simply put labels here. |
I'm new to JHipster so unfortunately don't have any history on what the expected behaviour is but I've done some investigation which will hopefully be useful. I can potentially investigate further if someone can clarify what the expected behaviour is.
With Hazelcast I've found that and for ehcache https://www.jhipster.tech/using-cache/ states
UPDATE - since first adding this comment I've found that the name used in CacheConfiguration is probably the same name that hibernate would use for the 2nd level cache if it were creating the cache itself based on the Entity class name so it's probably a way to customise the 2nd level cache rather than being a separate Spring Cache. application-dev.yml has the hazelcast management-centre disabled by default and links to http://docs.hazelcast.org/docs/management-center/3.9/manual/html/Deploying_and_Starting.html which I've followed to enable it (using the same version as JHipster (3.12.7 as it's not compatible with the latest 4.x). I had to set the following VM options when starting the Spring Boot app It may be worth splitting this into multiple issues / tasks when it's better understood:
This issue says
which based on the wording I think is viewing an individual entity e.g. this url http://localhost:9000/task/10/view rather than viewing a page of entities / Tasks http://localhost:9000/task but it would be useful to clarify this as the hibernate query cache is disabled by default in application.yml
I think the query cache would rely on the 2nd level cache rather than storing the full entity state itself which could explain why the entity cache gets populated during The screenshot of the statistics shows numbers that are exactly multiples of 10 (the number of faker items generated by default) so I think it's important to clarify whether there is an expectation that a query cache will be available or not rather than just a hibernate 2nd level cache without a query cache. |
The default page size is 20 but only 10 faker entities seem to get created so there's only half a page when an application is first generated. ehcache with CacheConfiguration line deleted:
ehcache with CacheConfiguration unchanged:
hazelcast with CacheConfiguration unchanged:
|
I've added the following code into
The SQL run each time is Is this the expected behaviour of JHipster to cache the entities for all results when doing a |
https://github.com/jhipster/jhipster/blob/master/jhipster-framework/src/main/java/io/github/jhipster/config/metric/JHipsterMetricsEndpoint.java#L182 doesn't put When using Hazelcast, Comparison of statistics available in ehcache, caffeine: I found these useful when investigating: |
to avoid this issue, I have to rewrite persistence layer, migrate to Ignite and sql2o |
@vudangngoc are you able to provide more clarification on exactly what the issue is from your perspective?
|
|
@vudangngoc Thanks for the additional information.
https://www.jhipster.tech/using-cache/ explains how to change the configuration to limit the size of the cache
|
@alansegar Thank you for your very detail information
|
It's been a month since this issue had any activity. I'm closing it. Please create a PR and re-open it if you have a solution. |
Overview of the issue
I create a new project with default configuration of Jhipster with MySQL, Hibernate and Hazelcast as cache layer 2. It seems that Hibernate cannot read from its layer 2 cache but put a lot of entities, the image bellow is screenshot of cache statistic
Could you please give me some clues to fix this issue? Thank you in advance!
JHipster configuration
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
java version "11.0.6" 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)
git version 2.7.4
node: v12.16.1
npm: 6.14.4
INFO! Congratulations, JHipster execution is complete!
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryBrowsers and Operating System
The text was updated successfully, but these errors were encountered: