bug:Caused by: org.attoparser.ParseException: failed to lazily initialize a collection of role

Caused by: org.attoparser.ParseException: failed to lazily initialize a collection of role: com.zzz.blog.domain.Album.images, could not initialize proxy - no Session

扩大sessio域也不管用时,就将所在变量添加fetch模式

//fetch=FetchType.EAGER饥渴模式
@OneToMany(targetEntity=Image.class, fetch=FetchType.EAGER)
	@JoinColumn(name="album_id")
	private Set<Image> images = new HashSet<Image>();

外键连接的对应变量也改一下fetch

	@ManyToOne(targetEntity = Album.class, fetch=FetchType.EAGER)
	@JoinColumn(name = "album_id")
	private Album album;

你可能感兴趣的:(Bug,bug)