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