无法延迟初始化角色集合:GeneratedDocument.listDocFields,无法初始化代理-无会话

时间:2018-08-01 14:30:51

标签: mysql spring hibernate jpa

@SequenceGenerator(name="seqGenDoc",initialValue=1)
public class GeneratedDocument implements Serializable{
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="seqGenDoc")
    private long id;
    private String label;
    private String path;
    @ManyToOne
    @JoinColumn(name="CODE_USER_GENERATEDBY")
    private User generatedBy;
    private float version;
    //@Temporal(TemporalType.DATE)
    private Instant creationDate;
    @OneToMany(mappedBy="documentGenerated",fetch=FetchType.LAZY)
    private Collection<GeneratedDocumentFields> listDocFields;
    @OneToMany(mappedBy="generatedDocument",fetch=FetchType.LAZY)
    private Collection<HistoryDocument> listHistoryDoc;

公共接口GeneratedDocumentRepository扩展了JpaRepository {

@Query("select gd from GeneratedDocument gd left join fetch gd.generatedBy gb where gb.id=:x")
public List<GeneratedDocument> ListGenDocByUser(@Param("x")Long id);

} 该怎么办?

0 个答案:

没有答案