Hibernate provides facility to do update , insert , delete by using
session.update, session.delete, session.save.
At the same time, we have concept of named queries which also provides facility of insert,update, delete as shown below....
<query name="delete">
delete Table1 c where c.column11 = :name
</query>
<query name="update">
update Table1 c set c.column11 ='updaetd' where c.column12 = :parameter
</query>
In my view for me updation using named queries looks fast as it require just one DB call, but if I am using session.update(Object obj), I have to read the row of a table in obj, change it, then call session.update(Object obj) method to save it
Can any one provide me in which situation, which approach shall be adopted. Basically I am looking at the guidelines which shall say, when to use session.update and when to use named queries and so on.
Thanks
Sudhir
|