当Gson解析Java对象中包含对象集合时,后面代码不执行
对象:
private long user_id;
private String user_name;
private String user_password;
private Date user_date;
private int age;
private String email;
private String phone;
private String user_sex;
private Timestamp user_registDate;
private String user_vip;
private Timestamp user_vipDate;
private String user_head;
private Set<IpAddress> user_ips = new HashSet<IpAddress>();
解析代码:
Query query = session.createQuery("from UserInfo as u where u.phone=?0 and u.user_password=?1");
query.setParameter(0, userInfo.getPhone());
query.setParameter(1, Crypto.encryption(userInfo.getUser_password()));
UserInfo user = (UserInfo) query.uniqueResult();
JsonObject json = new JsonObject();
String us = gson.toJson(user);
执行到String us = gson.toJson(user);这句时,当Ste<IpAddress>的值为一个时正常执行,当Set<IpAddress>值为多个时后面的代码不执行。