If the set of Role types is static in relation to your end-to-end release cycle, I would suggest mapping each with a separate <one-to-one> relation. This gives you the benefit of being able to add methods to manage specific roles at compile time. But of course it also limits you to those roles.
If you expect to add to the types of roles more often and easily, maybe so that consuming projects won't break if you add a role with a new version of your domain objects, I would suggest reworking your database and mappings for a proper inheritance mapping (table-per-hierarchy or table-per-subclass).
If you want to add to your role types dynamically at run time, I would suggest leaving off inheritance altogether (unless it is to support a class of roles), and make CustomerRole an association between Customer and a new RoleType class.
I would not suggest using a polymorphic collection like the one you have begun devising, first because it won't work without re-engineering the keys, and second because even when it is working, table-per-concrete-class is pretty ugly and it doesn't really give you any benefit over the <one-to-one> mapping described above.
Good move going with the Role pattern here. Lots of folks get stuck on trying to stuff that idea into an inheritance model, which fails for the exact reasons you cite.
|