【发布时间】:2011-03-12 08:55:33
【问题描述】:
如果我在对象类中有这个方法:
@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;
}
我将@cache 放在ObjectEntry 和Object 上
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Object extends HashCodeValidator {
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ObjectEntry extends HashCodeValidator
我还需要像这样将@cache 放在getObjectEntries 上吗:
@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;
}
如果我特别添加,是否需要为每个查询定义缓存
hibernate.cache.use_query_cache = true
?
【问题讨论】:
标签: java hibernate orm second-level-cache query-cache