Hi,
There is a basic problem which remains unclear to me.
I plan to create a set of persistent classes mapped with a surrogate key (of type guid) as their primary key. I also have some uniqueness constraint that I would like to comply with.
For instance, i have a Host class made unique by the "name" property. I don't want two Host objects with the same name to be persisted as two different objects. It then seems that there is a conflict between using a surrogate key and having uniqueness constraints. With a surrogate key as a primary key how can I enforce the uniqueness constraints ? Does this mean that using a surrogate key is not suited in this case ? (although surrogate keys are always recommended over natural keys) Am i bound to revert back to using a natural key ? (like using the name property as the primary key for the Host persistent class).
Thanks in advance,
|