I've got a set of classes using a common multi-field identity (and another common field), so I want to use an abstract base class for this. The relevant documentation says:
"The corresponding fields of the persistence capable class need not be public, and may also be defined in a persistent base class of this persistent capable class"
I also need horizontal inheritance (completely separate table for each concrete class). This is also mentioned in the documentation:
"While using single or multiple field identity, it is required that the horizontally mapped class is declared abstract.
In case of horizontal mapping, the identity and version information is specified at the next derived class, and if the IdentityField and the VersionField specified are fields that belong to the base class, those fields have to be accessible from the derived classes. Therefore, declaring these fields as "Protected" might be the best way, since if these fields are declared as "Private" the enhanced code will not be able to access these fields."
I followed this through but I can only get it to work if the identity fields are defined by the concrete class. The code is (essentially):
and the corresponding mappings
[The base class - AuditObject - and the concrete class - Country_Audit - are actually in separate assemblies.]
My unit test for this produces an exception:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> Telerik.OpenAccess.Exceptions.MetadataException : Unable to find primary key field 'lockVersion' for class 'MSW.MAPS.Testbed.Domain.Country_Audit'.
It works fine if I move the lockVersion field into the concrete class (really, I want the entityID field in the base class too; if I do that, I get the equivalent error for that field).
What am I missing? (or is this a bug?)
Best regards, Peter