开发者

OneToOne with shared key (MapsId) and lazy loading problem

My entities are:

@Entity
public class ReportSnapshot extends LightEntity {
  @Id
  @GeneratedValue
  private long id;

  @OneToOne(fetch = FetchType.LAZY, optional = false, mappedBy = "snapshot")
  private ReportContents contents;

  @Embedded
  private WeekNumber week;
  ...
}

and

@Entity
public class ReportContents extends LightEntity {
  @Id
  private long id;

  @MapsId
  @OneToOne(optional = false)
  private ReportSnapshot snapsh开发者_如何学编程ot;

  @Lob
  @Column(nullable = false)
  private String reportText = "";
  ...
}

here light entity class comes from gilead project and is intended for gwt serialization support - it shudn't affect the process. What i observe is: when I load ReportSnapshot by id from an entity manager, I automatically get the linked ReportContents despite the lazy association. According to what I've read that shudn't be hppening as I've set my relationship to be non-optional =(


Which provider are you using? Hibernate does not support lazy loading of OneToOne associations (at least not out of the box). That page documents some approaches you could try.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜