spring data jpa 怎么分页
1个回答
展开全部
private long userId;
private String content;
private String image;
private String smallImage;
private int supportCount;
private int unSupportCount;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "yuLu")
private Set<YuLuComment> items = new HashSet<YuLuComment>();
}
@Entity
@Table(name="TB_JSJGlobal_YuLuComment")
public class YuLuComment {
@Id
@GeneratedValue
private long id ;
private long userId ; // 哪个用户发表的语录
private String comment ;
private String userName ; // 评论用户的名字
// optional=true:可选,表示此对象可以没有,可以为null;false表示必须存在
@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }, optional = true)
@JoinColumn(name = "yulu_id")
private YuLu yuLu;
}
// 对语录评论进行保存
@Override
public Page<YuLuComment> findYuLuComment(long yulu_id, int page,
int pageSize) {
// 设置查询相关
Sort sort = new Sort(Direction.DESC, "id");
Pageable pageable = new PageRequest(page, pageSize, sort);
Specification<YuLuComment> spec = new UpcomingConferences(yulu_id);
private String content;
private String image;
private String smallImage;
private int supportCount;
private int unSupportCount;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "yuLu")
private Set<YuLuComment> items = new HashSet<YuLuComment>();
}
@Entity
@Table(name="TB_JSJGlobal_YuLuComment")
public class YuLuComment {
@Id
@GeneratedValue
private long id ;
private long userId ; // 哪个用户发表的语录
private String comment ;
private String userName ; // 评论用户的名字
// optional=true:可选,表示此对象可以没有,可以为null;false表示必须存在
@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.MERGE }, optional = true)
@JoinColumn(name = "yulu_id")
private YuLu yuLu;
}
// 对语录评论进行保存
@Override
public Page<YuLuComment> findYuLuComment(long yulu_id, int page,
int pageSize) {
// 设置查询相关
Sort sort = new Sort(Direction.DESC, "id");
Pageable pageable = new PageRequest(page, pageSize, sort);
Specification<YuLuComment> spec = new UpcomingConferences(yulu_id);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询