I have a self-tracking entity object (Phone) which has a nullable boolean property (PrimaryPhone) and which has the concurrency mode set to fixed. If I retrieve a record from the table tied to the entity object (SO$ENTITY.PHONES) and there is a value other than null in the field tied to the boolean property, I can update the row. However, if the field has a null value and I try to update the row, an OptimisticConcurrencyException is thrown. If, however, I set the concurrency mode to none, then the row can be updated. This is true when different object contexts are used when the data is retrieved then later updated. This is due to the fact that the data is being sent through a WCF service and so I don't maintain the object context between calls.
This is the SQL generated:
UPDATE "SO$ENTITY".PHONES
SET ENTITY_ID = :p0,
COUNTRY_CODE = NULL,
PHONE_NUMBER = :p1,
EXTENSION = NULL,
PRIMARY_PHONE = :p2,
BEST_TIME_TO_CALL = NULL,
COMMENTS = :p3,
PHONE_TYPE = :p4,
STATUS = :p5
WHERE ID = :p6
AND ENTITY_ID = :p7
AND (COUNTRY_CODE IS NULL)
AND PHONE_NUMBER = :p8
AND (EXTENSION IS NULL)
AND PRIMARY_PHONE = :p9
AND (BEST_TIME_TO_CALL IS NULL)
AND COMMENTS = :p10
AND PHONE_TYPE = :p11
AND STATUS = :p12
As you can see, it is trying to compare the nullable boolean field PRIMARY_PHONE to a value :p9 (which was NULL) when it should be using the IS NULL comparison if the value was NULL previously. However, if there was a value before, then the above statement would be correct.
I was wondering if there is a way to fix this problem without turning off concurrency checking.
Thanks.