Hi All, Does hibernate sessions in different JVMs can handle dirty reads? We have a single database instance accessed by multiple instances of the same web app. Each HTTP request opens the hibernate tranaction and closes it at the end of it.We do updates to inventory table on each request.Inventory table is mapped as below <class name="Inventory" table="Inventory"> <id name="uid" column="uid" type="int" unsaved-value="-1"> <generator class="identity" /> </id> <property name="quantityAvailable"/> <property name="quantitySold"/> <property name="inventoryForYear"/> <property name="name"/> <property name="soldOutDate"/> </class>
inventory.setQuantitySold(inventory.getQuantitySold() + 1); to increase and using saveOrUpdate to update inventory.setQuantitySold(inventory.getQuantitySold() - 1); to decrease using saveOrUpdate to update
As each app instance have its own hibernate session , is there any chance that inventory.getQuantitySold() result in a dirty read, i mean a value updated by instance 2, read by instance 1,and rolled back by instance 2.Does database take care of dirty reads issue or do i need to declare anything specific in hibernate mapping?
when we run SQL queries directly on DB,at the end of day,We see the difference between inventory table's quantitysold value and number of actual items sold.
Thanks, rK
|