Understanding Sleep Cache

If I have this method in an object class:

@OneToMany( fetch = FetchType.EAGER,
    cascade = { CascadeType.ALL },
    mappedBy = "object"  )
@org.hibernate.annotations.Cascade(
    {org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@Column( nullable = false  )
public Set<ObjectEntry> getObjectEntries() {
    return this.objectEntries;
}

and I put @cacheboth on ObjectEntryand onObject

@Cache(usage =  CacheConcurrencyStrategy.READ_WRITE)
public class Object extends HashCodeValidator {

@Cache(usage =  CacheConcurrencyStrategy.READ_WRITE)
public class ObjectEntry extends HashCodeValidator 

Should I still put @cache on getObjectEntries like this:

@org.hibernate.annotations.Cascade(
    {org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@Column( nullable = false  )
@Cache(usage =  CacheConcurrencyStrategy.READ_WRITE)
public Set<ObjectEntry> getObjectEntries() {
    return this.objectEntries;
}

Do I need to define a cache for each request, if I specifically add

hibernate.cache.use_query_cache = true

?

+3
source share
1 answer

(...) Should I still put @cache on getObjectEntries as follows:

Yes, you should still cache the collection if you want (which will be cached in a specific area of ​​the cache).

Do I need to define a cache for each request, if I specifically add hibernate.cache.use_query_cache = true

hibernate.cache.use_query_cache ( 3.4. ):

. - . , true | false

, , cachable ( setCacheable(true) ), - .

0

Source: https://habr.com/ru/post/1753328/


All Articles