There is no need to call a particular method
, which has a different purpose) to make the application and database modifications persistent.Transactional persistent instances (objects loaded, saved, created or queried by the Session) can be manipulated by the application, and any changes to persistent state will be persisted when the Session is flushed. So we can say that there is no need to call a particular method. The most straightforward way to update the state of an object is to load() it and then manipulate it directly while the Session
DomesticStudent student = (DomesticStudent) session.load( Student.class, new Long(69) );
sess.flush(); //Here changes to student are automatically detected and persisted
In the Hibernate Sometimes the programming model is inefficient, as it requires in the same session both an SQL SELECT to load an object and an SQL UPDATE to persist its updated state. Hibernate offers an alternate approach by using detached instances.
We need to remember the below points in the Hibernate:
1. Hibernate does not offer its own API for direct execution of UPDATE or DELETE statements.
2. Hibernate is a state management service, you do not have to think in statements to use it.
3. JDBC is a perfect API for executing SQL statements, you can get a JDBC Connection at any time by calling session.connection(). Furthermore, the notion of mass operations conflicts with object/relational mapping for online transaction processing-oriented applications.
4. We use the Batch processing for some possible batch operation tricks.