0
@ LastModifiedByアノテーションを使用して多対一列を遅延ロードする方法はありますか?例えばLazy @LastModifiedBy
私はCREATEDBYとlastModifiedByの列があります。
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "manager_id")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
private User manager;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@CreatedBy
@JoinColumn(name = "created_by")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
@JsonProperty("created_user_id")
private User createdBy;
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@LastModifiedBy
@JoinColumn(name = "last_modified_by")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
@JsonProperty("last_modified_user_id")
private User lastModifiedBy;
それが仕事です。しかし、すぐに、私は怠惰な負荷列lastModifiedByしようとして、私が持っている(FetchType.LAZY、= falseのオプション=フェッチ)エラー:
2016-06-18 23:10:36,399 WARN [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-8) Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Problem accessing property 'id': null (through reference chain: com.smcontact.cms.model.project.Project["manager"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Problem accessing property 'id': null (through reference chain: com.smcontact.cms.model.project.Project["manager"])
どのようにこのエラーを修正するには?