后台使用hibernate的findByCriteria方法进行查询
[code="java"]@RequestMapping(value="/list")
@ResponseBody
public DataResponse list(@RequestParam("page") String page,
@RequestParam("rows") String rows,
@RequestParam("sidx") String sidx,
@RequestParam("sord") String sord
){
try {
DataRequest request = new DataRequest();
request.setPage(StringUtils.isEmpty(page) ? 1 : Integer.valueOf(page));
request.setRows(StringUtils.isEmpty(rows) ? 20 : Integer.valueOf(rows));
request.setSidx(sidx);
request.setSord(sord);
return customSearchUtil.search(request, User.class);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}[/code]
customSearchUtil.search方法只是调用findByCriteria然后把数据返回.
User类我已将一个多对多的属性针对JSON进行屏蔽
代码执行到return 语句都只打印了一句sql查询语句
但是方法结束到前台显示就会打印出查询role信息的sql语句
请问这是jqgrid的问题吗?
实体类如下
[code="java"]@Entity
@Table(name="SYS_USER")
@JsonIgnoreProperties(value={"hibernateLazyInitializer", "roles"})
public class User implements Serializable, UserDetails {
@Id
@SequenceGenerator(name = "SEQ_USER", sequenceName = "SEQ_USER")
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "SEQ_USER")
private Integer id;
@Column(name = "USERNAME", length = 100, nullable = false)
private String username;
@Column(name = "FULLNAME", length = 255)
private String fullname;
@Column(name = "PASSWORD", nullable = false)
private String password;
@Column(name = "ENABLED")
private Integer isEnabled;
@Column(name = "IS_ADMIN")
private Integer isAdmin;
@Column(name = "VERSION")
private Integer version;
@Cascade(value={CascadeType.SAVE_UPDATE})
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(schema = "TRAIN", name = "SYS_USER_ROLE", joinColumns = { @JoinColumn(name = "USER_ID", referencedColumnName = "ID", nullable = false) }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID", nullable = false) })
Set<Role> roles;[/code]