In my application following is the scenario, client request for eventId. In server side,open new session-> create new eventId is created, and store it in database and that eventId is sent to the client-> close the session.
And after that client using that eventId send VO the server. And in the server side, we check first for the that eventId present or not using session.get() method.
But problem is that every time session.get() method gives random behaviour, means sometimes it says eventId is present and sometimes not present.
Code for checking eventID is present or not :
Session session = HibernateUtil.currentSession();
Event event = (Event) session.get(Event.class,eventId);
if(event != null){
syso("Event is present");
} else {
syso("Event is not present");
}
Can anyone explain what is problem? This is due to session is remain open or anything else.
You are using Transactions that sometimes not yet has been Committed to the database.
Try
Regards