-->
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.  [ 5 posts ] 
Author Message
 Post subject: Trouble w/ saveOrUpdate()
PostPosted: Fri May 14, 2004 5:22 pm 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
Hi,

I have a case where I'm invoking saveOrUpdate(), where I expect the object to be updated. Instead, it's getting saved (I have hibernate.show_sql:true, and I'm seeing SQL inserts instead of updates). I set the log level to debug, but unfortunately the first message it prints is

Code:
DEBUG - saving [com.my.class.Name#<null>]


Not sure why it thinks it's "#null"! I put in some scaffolding to print the identifier property of the object, and it's not null


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 6:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
answer is most likely: fix your getId() method.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 6:50 pm 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
Hmmm, thanks...

here's what my id property looks like:

Code:
   /**
    * @hibernate.id
    *   generator-class="native"
    *   column="id"
    */
   public Long getId() {
      return _id;
   }
   public void setId(Long id) {
      _id = id;
   }


I'm having trouble imagining what it should be other than this...? Any other possibilities? Does the scenario I outlined conform to "best practice" for using Hibernate in a Web application?

thanks,
mark


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 7:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please make sure you are not accidentially overwriting the id with null in your steps 4/5.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 9:52 pm 
Newbie

Joined: Fri May 14, 2004 9:34 pm
Posts: 1
How about check your unsaved-value?


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