简体   繁体   中英

Spring, Hibernate and Ehcache - Wrong entities

I've got a webapp which uses spring+hibernate for my data layer. I'm using 2nd level caching with ehcache as provider. Everything seems to work so far but sometimes we encounter a problem which I can't really figure out atm.

One of my tables is used for labels within the application - every user who logs access this table with his set language. Works for 90% of the time. But sometimes the user gets labels for the wrong language, eg instead of german everything turns to italian.

After a logout and login all labels are correct.

Does anyone of you encountered something like this? I'm not sure where to look at: spring+hibernate+ehcache is a solid package or is it not?

Cheers

Spring/Hibernate/EhCache is a solid stack, I'm 99% sure it's a bug in your code.

Any chance the labels are cached statically somewhere in your application?

Make sure equals and hashcode are proprerly implemented in your entity classes, you can find insights on how to do it here

Try to remote debug your server, set breakpoints in your DAOs to check that the data is actually fetched.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM