-->
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.  [ 9 posts ] 
Author Message
 Post subject: persisting data with saveOrUpdate() -- question
PostPosted: Fri Sep 12, 2003 2:13 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
i am using the statment block:
Code:
      
try
{
    ses.saveOrUpdate( obj );
    ses.connection().commit();
}
catch( Exception e )
{
..
}
to persist a change to an object and the save does not seem to work. I get the object as a result of one session and then do the saveOrUpdate on another session. In the mapping file, i set the unsaved-value=none to be sure an update will occur.

Any and all help is greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
flush() the session.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:32 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
That didn't work, the code now looks like this:
Code:
   protected void storeObject( Session ses, Object obj )
   throws DAOException
   {
      try
      {
         ses.saveOrUpdate( obj );
         ses.connection().commit();
         ses.flush();
      }
      catch( Exception e )
      {
         // if we have an exception try to roll back
         try
         {
            ses.connection().rollback();
         }
         catch( Exception ex )
         {
            CPLog.persistence.fatal( e.toString() );
         }

         ;
         throw new DAOException( e );
      }
   } // end storeObject


Something is wrong and there is nothing weird in the log file... any other thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
LOL!


You flush() the session _before_ committing, obviously!


look, all this is documented in the Hibernate manual and is even the first question in the FAQ.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:46 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
yes, so i had is backwards i figured that out, thank you for not flaming me too much, afterall it is late on friday :-)

now i get this exception... if you guys want to flame me more go right ahead i can take it.

SQL Exception
java.sql.BatchUpdateException: ORA-01006: bind variable does not exist


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
dunno. what happens if you disable batch updates?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 3:07 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
i have it working, what i did was modify my mapping document and removed the cascade attribute in my set collection. this probably is a hack isn't it?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 3:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
sounds like a hack to me


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 3:38 pm 
Beginner
Beginner

Joined: Fri Sep 05, 2003 10:17 am
Posts: 42
yeah, i will need to figure this one out... looks like the cascade is causing issues. i will report back with my findings. Thanks for your help, i appreciate it, and next time i will try to do a bit more reading before blasting off with a question.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.