Optimistic concurrency doesn't works: no OptimisticConcurrencyException is
thrown
---------------------------------------------------------------------------------
Key: DNET-400
URL: http://tracker.firebirdsql.org/browse/DNET-400
Project: .NET Data provider
Issue Type: Bug
Components: Entity Framework support
Affects Versions: 2.6.5
Environment: Entity Framework 4.1 (Code First), Firebird 2.5.1
Reporter: Dennis
Assignee: Jiri Cincura
How to reproduce the bug:
1) Create POCO entity class:
public class TestEntity
{
public int Id { get; private set; }
public string Name { get; set; }
public long? ObjectVersion { get; private set; }
}
2) Configure this class with code first.
2.1) "Id" must be an identity property:
Property(obj => obj.Id)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
2.2) "ObjectVersion" must be a computed concurrency token:
Property(obj => obj.ObjectVersion)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed)
.HasColumnName("ObjectVersion")
.IsConcurrencyToken(true);
3) Create Firebird database:
3.1) one table, corresponding to the entity type;
3.2) the sequence to generate values for "Id" column and the trigger (before
insert) to set values of "Id" column;
3.3) the sequence to generate values for "ObjectVersion" column and the trigger
(before insert/update) to set values of "ObjectVersion" column;
4) Run test:
4.1) create first instance of the context, load any TestEntity entity from the
database;
4.2) create second instance of the context, load [b]the same[/b] TestEntity
entity from the database;
4.3) change "Name" property of entity, loaded via first instance of the context
and save changes. "ObjectVersion" property will be incremented.
4.4) change "Name" property of entity, loaded via second instance of the
context and save changes. "ObjectVersion" property will be set to null. No
OptimisticConcurrencyException will be thrown, although it must be.
Remark: changing the type of "ObjectVersion" property to non-nullable Int64
brings to an exception, but this is materialization-related exception (trying
to assign null to a non-nullable property). To throw
OptimisticConcurrencyException, this query:
EXECUTE BLOCK (
p0 BLOB SUB_TYPE TEXT = @p0, p1 INT = @p1, p2 BIGINT = @p2)
RETURNS (
"ObjectVersion" BIGINT)
AS BEGIN
UPDATE "TestEntity"
SET "Name" = :p0
WHERE (("Id" = :p1) and ("ObjectVersion" = :p2))
RETURNING "ObjectVersion" INTO :"ObjectVersion";
SUSPEND;
END
must set correctly rows affected.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider