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.  [ 3 posts ] 
Author Message
 Post subject: problem with update
PostPosted: Mon Jul 31, 2006 6:32 am 
Beginner
Beginner

Joined: Thu Jun 22, 2006 8:56 am
Posts: 22
Hello,

i dont know why my update does not work:
Code:
Integer nr = 5;
Query query = session.createQuery("from Source as source where source.nr = '"+ nr + "' " );
Source found_final =(Source)query.uniqueResult();
if (found_final == null){
found = new Source(source);
session.save(found);
}
                  
else{   
session.saveOrUpdate(found_final);
}


Can anyoune help?

Thank you,
seven-12


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 10:19 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
Two things:

1. Learn how to post a proper request for help.
2. Are you aware that this is the NHibernate forum which deals with the C# port of Hibernate and NOT the main Hibernate forum?

Cheers,
Radu


Top
 Profile  
 
 Post subject: Re: problem with update
PostPosted: Mon Jul 31, 2006 12:04 pm 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
seven-12 wrote:
i dont know why my update does not work:
Code:
Integer nr = 5;
Query query = session.createQuery("from Source as source where source.nr = '"+ nr + "' " );
Source found_final =(Source)query.uniqueResult();
if (found_final == null){
found = new Source(source);
session.save(found);
}
                  
else{   
session.saveOrUpdate(found_final);
}


Can anyoune help?


I have never worked with Hibernate (for Java), but in NHibernate Session.SaveOrUpdate only associates the detached persistent object with session - and is needed only if You loaded object trogh another session and then disconnected it. In order to save changes to database, call session.Flush();

Gert

_________________
If a reply helps You, rate it!


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