Realted to optimistic locking using @version field -- "If you dont specify an @version field, the entity manager has to walk through each field in entity insatnce and compare its value to corresponding, mapped column in the database, which is far more laborious"
Statement is taken from "Beginning EJB 3 application development" By RaghuR. Kodali, Jonathan Wetherbee, Peter Zadrozny -- Page 142- para 1
Does this statement means, even if i dont use "@version" still it will give me optimisticLockException by checking column in database if its updated??? .... How???
This behaviour is not included in JPA! It's a hibernate feature. JPA only known versioning using a version attribute.
In hbm.xml you can set <class... optimistic-lock="all"> so Hibernate lists the last value of all fields in an update statement.
E.g. "update xyz set foo = ?, bar =? where id = 123 and foo ='bla' and bar = 'blubb'".
With Annotations you can do the same with "@org.hibernate.annotations.Entity(optimisticLock = org.hibernate.annotations.OptimisticLockType.ALL)
If you use JBoss you have Hibernate as JPA-provider, so you don't have to deploy any additional libs.