-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Batch Saves
PostPosted: Fri Jun 03, 2005 2:19 pm 
Beginner
Beginner

Joined: Thu Oct 23, 2003 11:22 am
Posts: 20
Hibernate version: 2.1.1

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 0, of class: com.gsk.les.bo.himpl.IHNotesDatabaseSpec
at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1605)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1377)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1403)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1327)
at com.gsk.les.bp.himpl.IHBizObjBPs.genericBulkSaveOrUpdate(IHBizObjBPs.java:135)
at test.TestBulk.main(TestBulk.java:24)

Name and version of the database you are using: Oracle

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am attempting to create several transients and then conduct a bulk initial save of them. Here is an example of a simple (test) version that generates this issue:

Code:
BizObjBPs bps = BPFactory.createBizObjBPs();
        NotesDatabaseSpec n1 = bps.createTransientNotesDatabaseSpec();
        NotesDatabaseSpec n2 = bps.createTransientNotesDatabaseSpec();
        List l = new ArrayList();
        l.add(n1);
        l.add(n2);
        bps.genericBulkSaveOrUpdate(l);


The code in the "genericBulkSaveOrUpdate is:

Code:
int count = 0;
      Session s = DBUtil.getDBUtilInstance().getSession();
      Transaction tx = null;
      try {
         s.reconnect();
         tx = s.beginTransaction();
         for(Iterator it = l.iterator(); it.hasNext();) {
            s.saveOrUpdate(it.next());
            count++;
            if(count >= BizObjBPs.BULK_GRP_SIZE) {
               tx.commit();
               tx = s.beginTransaction();
               count = 0;
            }
         }
         tx.commit();
      } catch(Exception hex) {
         if(tx != null)
            try {
               tx.rollback();
            } catch(Exception ex2) {
               ex2.printStackTrace();
            }
         hex.printStackTrace();
      } finally {
         try {
            s.disconnect();
         } catch(Exception hex) {
            hex.printStackTrace();
         }
      }


Basically this code has worked in the past and suddenly I am getting this NonUniqueObjectException. Why is this not working?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 10:43 am 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
Generator? xml map files? put more info
http://www.hibernate.org/ForumMailinglists/HowToAskForHelp


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.