Loading...

          java .net

          google app engine for java:org.datanucleus.exceptions.NucleusUserException

          開發中遇到這個異常:
          NestedThrowablesStackTrace:
          Attempt was made to manually set the id component of a Key primary key. If you want to control the value of the primary key, set the name component instead.
          org.datanucleus.exceptions.NucleusUserException: Attempt was made to manually set the id component of a Key primary key. If you want to control the value of the primary key, set the name component instead.


          原來的修改代碼是這樣些的:
          public void attachDirty(UrlTarget instance) {
                  PersistenceManager pm = null;
                  try {
                     
                      pm = PMF.get().getPersistenceManager();
                      UrlTarget ut = (UrlTarget) pm.getObjectById(UrlTarget.class, instance.getId());
                      ut.setName(instance.getName());
                      ut.setRemark(instance.getRemark());
                      ut.setUrl(instance.getUrl());
                     pm.makePersistent(ut);
                  } catch(Exception ex){
                      ex.printStackTrace();
                  }finally {
                      if(pm != null)pm.close();
                  }
                 
              }

          public UrlTarget findById(Long id) {
                  PersistenceManager pm = PMF.get().getPersistenceManager();
                  try{
                      return (UrlTarget) pm.getObjectById(UrlTarget.class, id);
                  }catch(Exception ex){
                      ex.printStackTrace();
                  }finally {
                      pm.close();
                  }
                  return null;
              }
          在利用findById方法得到對象后修改,但是findById中pm已經關閉,這就是錯誤的原因了

          posted on 2009-10-14 18:01 閱讀(420) 評論(0)  編輯  收藏 所屬分類: 學習java

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2009年10月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 油尖旺区| 平谷区| 成武县| 仁布县| 涿鹿县| 甘南县| 吴桥县| 祁阳县| 纳雍县| 定陶县| 雅安市| 大冶市| 新和县| 阳东县| 会同县| 九寨沟县| 迭部县| 奉贤区| 利辛县| 修水县| 长泰县| 芜湖市| 洪洞县| 江陵县| 富裕县| 沧源| 泸州市| 新泰市| 洪泽县| 建昌县| 通辽市| 贡觉县| 珠海市| 东阿县| 于田县| 东丰县| 芦溪县| 泸水县| 白山市| 青岛市| 麻城市|