如何使用Hibernate.initialize()从List <object>获取第一个对象?

时间:2016-10-22 22:22:47

标签: java hibernate

示例:

@OneToMany(fetch=FetchType.LAZY, mappedBy="album", cascade=CascadeType.ALL)
private List<Photo> listPhoto;

List<Album> albums = (List<Album>) criteria.list();
for(Album album : albums) {
  Hibernate.initialize(album.getListPhoto().get(0));
}

当我这样做时,给我带来List中的所有Object,我只需要First Object,即使是.get(0)

0 个答案:

没有答案