Optimistic locking with SELECTED_COLUMNS
utdrewFeb 2 2009 — edited Feb 2 2009Hi,
I'm trying to get Eclipselink (v 1.0.2) to perform some optimistic locking on a timestamp column. I've annotated my class as follows:
@OptimisticLocking(type=OptimisticLockingType.SELECTED_COLUMNS,selectedColumns=@Column(name="modified_on"))
This appears to be working because my update query looks like this:
FINE: UPDATE rxa_formulary SET formulary_name = ?, modified_on = ? WHERE ((formulary_pk = ?) AND (modified_on = ?))
FINE: bind => [Test, 2009-02-02 19:34:21.287, 11108, 2009-02-02 19:18:53.534]
My problem is that this update does not succeed because I manually modified the modified_on column but eclipselink never generates any OptimisticLockException which is the behavior I expect based on this [wiki page|http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Extensions_for_Optimistic_Locking]. Have I misunderstood the behavior or is this a possible bug?
Here are the pertinent settings my persistence.xml if that helps.
<property name="eclipselink.logging.exceptions" value="WARNING" />
<property name="eclipselink.logging.logger" value="ServerLogger" />
<property name="eclipselink.target-server" value="SunAS9" />
<property name="eclipselink.logging.level" value="Finer" />
<property name="eclipselink.weaving" value="true" />
<property name="eclipselink.weaving.lazy" value="true" />
<property name="eclipselink.weaving.internal" value="true" />
<property name="eclipselink.jdbc.batch-writing" value="Oracle-JDBC" />
<property name="eclipselink.jdbc.batch-writing.size" value="1000" />
<property name="eclipselink.jdbc.native-sql" value="true" />
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
Thanks,
Drew