Suppose that I have 4 client socket threads. Someone swiped at terminal 1, client socket 1 reads the data and tries to insert a record in database, at the same time if another person swipes at other terminal say 2 or 3 or 4 the appropriate client socket will receive the data and tries to insert a record in database.
The Session interface is the primary interface used by Hibernate applications. An
instance of Session is lightweight and is inexpensive to create and destroy. This is
important because your application will need to create and destroy sessions all the
time, perhaps on every request. Hibernate sessions are not threadsafe and should
by design be used by only one thread at a time.
Now suppose XYZ swipes at terminal1, thread1 will read and hand over the data to session1. Since the outtime in session1 is null, the outtime will be noted. Whereas this time XYZ is inside the school.