hi,
i want to discuss two words used in hibernate which is synchronized and committed data.
i think committed data into database means data will be permanently updated in database and when we reopen the session and trying to get data, we will get that data from database and code for committing is:
Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); BallPlayer p = (BallPlayer)session.get(BallPlayer.class, 1L); p.setNickname("Bambino"); //synchronizing transaction.commit(); session.close();
Code for only synchronizing is:
Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); BallPlayer p = (BallPlayer)session.get(BallPlayer.class, 1L); p.setNickname("Bambino"); //synchronizing
in this way data is not updated in database and we can get updated data until session is not closed and when we close the session, then try to get that data, we will not get that data because it is not committed and was temporarily available
am i absolutely correct?
|