From the session.load javadoc
Quote:
You should not use this method to determine if an instance exists (use find() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
qasim wrote:
if (saved)
s.update(wwscore);
else
s.save(wwscore);
logger.info("Update of Candidate " + wwscore.getAppno());
Will always log "Update of Candidate " + wwscore.getAppno() because of {} missing.
If you load an object from a session, you don't have to call session.update. Hibernate knows when it is updated and will flush it.
Try this kind of code
Code:
List list = session.find("myrequest");
if (list.size() == 0) {
Object obj = new Object();
// fill object including id
session.save(obj);
} else {
Object obj = (Object) list.get(0);
//fill non id params
}