休眠不缓存我的一对一关系在反向侧
2022-09-03 16:14:01
我有这样的代码:
@Entity
@Table(name = "A")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class A
{
@OneToOne(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy="a")
public B getB() {};
}
@Entity
@Table(name = "B")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class B
{
@OneToOne(cascade={}, fetch=FetchType.LAZY)
@JoinColumn(name="A_ID")
public A getA() {};
}
每次加载时都有查询 。为什么在加载后不缓存,是否可以缓存它?A
B
A.getB()
A