解决方案 »

  1.   

    。。我把Job的关联映射都去掉了,还是出错误org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper with modifiers "public" at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243) at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165) at 
      

  2.   

    不会的路过~
    为啥你不让json序列化返回type又填的json?
      

  3.   

    不是很理解你的意思。主要感觉用struts的json会方便些<class name="com.bean.Job" table="JOB" lazy="true">今天发现如果我把lazy设置false就可以正常运行了,不过我account也是lazy=“true”的,为什么account可以而job不可以呢,很奇怪,而且不想修改配置文件,还在找原因
      

  4.   

    多次测试后发现是lazy导致,并非@JSON(serialize=false)不起效1去除所有关联,并设置lazy=false 成功
    <class name="com.bean.Job" table="JOB" lazy="false">
    1.1 去除所有关联,设置lazy=true 失败
    <class name="com.bean.Job" table="JOB" lazy="true">2在1的基础上加上dept(many-to-one)和Accounts(one-to-many)属性,不加映射,成功
    3加上dept映射, dept的lazy=proxy或flase,失败,有大量的SQL输出,dept本来也无法单个读出
     <many-to-one name="dept" class="com.bean.Dept" lazy="proxy">
    3.1 在3的基础上,到dept的get方法添加@JSON(serialize=false),成功4在3.1的基础上,给accounts加上映射,设置lazy=true或flase,inverse=true,成功,读出accounts(Account可单个读出,且lazy为true),输出SQL
    <set name="accounts" inverse="true" lazy="true">
    4.1在4的基础上,到accounts的get方法添加@JSON(serialize=false),成功,没读出accounts,没输出SQL
    Service.getByID()继承自同一父类:(T)getHibernateTemplate().get(TClass.getName(),id);
    5 Job采用Service.getByID()方法,lazy=true,失败
    5.1 loginUser采用Service.getByID()方法,成功
    5.2 Job采用Service.getByID()方法,lazy=false,成功account不管lazy是true还是false都成功,而job的lazy必须是false才可以