More JPA-2 locking support is checked in for HHH-4546. As per Steve's suggestion, we can now customize dialects to control how core locking (optimistic +pessimistic) is performed against different database servers.
We now have the following additional Hibernate LockModes that are used for JPA-2 locking: OPTIMISTIC - Verify that version hasn't changed just prior to transaction commit. OPTIMISTIC_FORCE_INCREMENT - Verify that version hasn't changed and increment version. Performed just prior to transaction commit. PESSIMISTIC_READ - Immediately obtain a read (or greater) entity database lock. PESSIMISTIC_WRITE - Immediately obtain a write entity database lock. PESSIMISTIC_FORCE_INCREMENT - Immediately obtain a write entity database lock and increment the version. I propose that we make the following database dialect changes for the above: 1. For Oracle, I believe that "select for update" is now getting a shared database lock. I propose that we tailor the Oracle dialect to do a "select for update" for LockMode.PESSIMISTIC_READ. The Oracle dialect should also handle LockMode.PESSIMISTIC_WRITE by using the above described behavior for LockMode.PESSIMISTIC_FORCE_INCREMENT (JPA-2 spec allows this). 2. For SQL Server dialect, we could use "holdlock, rowlock" for LockMode.PESSIMISTIC_READ and "updlock, rowlock" for LockMode.PESSIMISTIC_WRITE. There are probably other variations to consider (e.g. Snapshot Isolation mode). Perhaps we will get some community help in customizing the dialects. :-) -Scott On 11/06/2009 09:04 AM, Scott Marlow wrote: > Initial support for locking is checked in via HHH-4546. > > > _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev