我使用org.hibernate.tool.instrument.javassist.InstrumentTask
为使用maven-antrun-plugin的类应用了Hibernate字节码检测。类具有惰性@OneToOne
关系,如下所示:
@Entity
@Table(name = "tableName", schema = "...", catalog = "...")
public class FirstClass {
@Id
@Column(name = "id")
private long id;
@LazyToOne(LazyToOneOption.NO_PROXY)
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "secondClassId")
private SecondClass secondClass;
//accessors
}
@Entity
@Table(name = "tableName", schema = "...", catalog = "...")
public class SecondClass {
@Id
@Column(name = "id")
private long id;
//accessors
}
当我尝试使用Criteria或jpql获取属性secondClass
时,我看到" secondClass"在查看调试之后检索数据并且没有secondClass数据(但应该是)。
查询:
SELECT FC FROM FirstClass FC JOIN FETCH FC.secondClass
为什么会这样?有人知道如何解决它吗?