0

i have 3 classes

class A{
    List<B> child;
}

class B{
    List<C> child;
}

class C{
    String name;
}

in my application, class A will load by any request from users. am i should to use @Cache annotation above any classes? Should I use it above Lists or just put it above class A?

1 Answer 1

2

Hibernate has different regions for caching. If you want to cache a has-many collection, you can (ie the children for class B), but then the class that makes up the collection needs to be Cached as well. Ultimately it comes down to what you need and what you want to cache.

So in your case you could cache any of the classes, and in addition, any of the List's as well. Whether or not it makes sense to do so will probably require some load testing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.