NonUniqueObjectException

          org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session

          首先看看這個類:
          //$Id: NonUniqueObjectException.java,v 1.4 2005/02/12 07:19:50 steveebersole Exp $
          2
          package org.hibernate;
          3
          4 import java.io.Serializable JavaDoc;
          5
          6 import org.hibernate.pretty.MessageHelper;
          7
          8 /**
          9  * This exception is thrown when an operation would
          10  * break session-scoped identity. This occurs if the
          11  * user tries to associate two different instances of
          12  * the same Java class with a particular identifier,
          13  * in the scope of a single <tt>Session</tt>.
          14  *
          15  * @author Gavin King
          16  */

          17 public class NonUniqueObjectException extends HibernateException {
          18     private final Serializable JavaDoc identifier;
          19     private final String JavaDoc entityName;
          20
          21     public NonUniqueObjectException(String JavaDoc message, Serializable JavaDoc id, String JavaDoc clazz) {
          22         super(message);
          23         this.entityName = clazz;
          24         this.identifier = id;
          25     }
          26
          27     public NonUniqueObjectException(Serializable JavaDoc id, String JavaDoc clazz) {
          28         this("a different object with the same identifier value was already associated with the session", id, clazz);
          29     }
          30
          31     public Serializable JavaDoc getIdentifier() {
          32         return identifier;
          33     }
          34
          35     public String JavaDoc getMessage() {
          36         return super.getMessage() + ": " +
          37             MessageHelper.infoString(entityName, identifier);
          38     }
          39
          40     public String JavaDoc getEntityName() {
          41         return entityName;
          42     }
          43
          44 }


          解決方案:
               this..getSession().clear();

          posted on 2008-09-25 17:07 bill 閱讀(899) 評論(0)  編輯  收藏 所屬分類: Hibernate


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2008年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(1)

          隨筆分類(2)

          隨筆檔案(4)

          相冊

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 台中市| 大兴区| 东明县| 通山县| 铅山县| 黔西县| 彭阳县| 稷山县| 东兰县| 同心县| 藁城市| 怀安县| 和顺县| 西吉县| 定西市| 墨脱县| 迭部县| 荔浦县| 那曲县| 宣恩县| 克东县| 富蕴县| 鄱阳县| 彭阳县| 连云港市| 嘉定区| 温宿县| 长岭县| 延长县| 昆山市| 揭阳市| 大宁县| 洪江市| 芷江| 运城市| 吴桥县| 北京市| 贡山| 昭通市| 马关县| 恩施市|