有类:QuestionTrack
public class QuestionTrack implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer id;
private String roomAtTheManufacturers;
/** 测试厂家 */
private String testManufacturers;
/** 测试日期 */
private Date testDate;
set
get
……
}
数据库类:
public class QuestionTrackDAO{
public List<QuestionTrack> getAll() {
Session session = HibernateUtil.getCurrentSession();
String hql = "from QuestionTrack";
Query query = session.createQuery(hql);
return query.list();
}
有一action
public ActionForward getList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List questionTracklist = new ArrayList();
questionTracklist = questionTrackDao.getAll();
QuestionTrack track = new QuestionTrack();
QuestionTrack track2 = new QuestionTrack();
track.setId(1);
JSONObject jsonObject = JSONObject.fromObject(track);
questionTracklist.add(track);
questionTracklist.add(track2);
String array = JSONArray.fromObject(questionTracklist).toString();//一切正常
String array = JSONArray.fromObject(questionTracklist).toString();//如果是绿色部分,执行到这里挂掉
for (Iterator iter = questionTracklist.iterator(); iter.hasNext();) {
QuestionTrack questionTrack = (QuestionTrack) iter.next();
JSONObject.fromObject(questionTrack);
}
}
我用的是json-lib
对于以上的原因,我觉得应该是Hibernate引起的。不知道各位同仁有没有遇到这样的问题