[jrf-devel] PostgreSQL Timestamp Optimistic Locking...
Brought to you by:
joncrlsn
|
From: Mandip S. S. <ma...@su...> - 2002-04-10 10:22:30
|
Hi All Been working on getting all the tests to pass for PostgreSQL database and came up with an interesting issue... If we create a Domain that uses timestamp optimistic locking then the timestamp string in the db will look like: '2002-04-08 17:48:30.123456+01' However when we retrieve a PersistentObject from the table and hence read the timestamp column value (using rs.getTimestamp(columnName)) the timestamp string is stored as '2002-04-08 17:48:30.123'. If we now modify our PersistentObject and try to save it back to the db with a statement like: UPDATE Domain f1=..., f2=..., f3=..., WHERE id=... AND timestampColumnName='2002-04-08 17:48:30.123' Then the statement will obviously fail and we get an ObjectHasChangedException even though the row actually hasn't been updated since we last read from it. So the issue here being how do we get round the problem of different timestamp representations in the db and within the framework? To get round this problem I've changed the statement to: UPDATE Domain f1=..., f2=..., f3=..., WHERE id=... AND timestampColumnName LIKE '2002-04-08 17:48:30.123%' What do you guys think of the above change? Are there any other suggestions? Is this something we might have to put into the DatabasePolicy? Regards Mandip |