I have a class BaseEntity which has (for all intents and purposes here) just a GUID as a primary key, and an aggregation relationship with a class BaseRole. All roles in my framework are ultimately a specialization of BaseRole. More specifically each entity is really just several different roles with the same GUID. This is an implementation of the "Role-Relationship" approach seen Fowler's paper titled "Dealing with Roles". There are many "value" class dependencies that will key off of the GUID too. For instance there should only be one PersonDetail class for someone who is an (e.g. has the roles) Contractor, Driver, HumanResource, and LegalParty. To do this all value classes will key off the GUID as well.
Here's an example.
Code:
_____________ __________________
| BaseEntity | 1 * | BaseRole |
|------------|<>----------|-----------------|
|+GUID | |+roleName:String |
|------------| |-----------------|
|____________| |_________________|
/\
/ \
``|`
|
______________ |
|PersonDetail| _______|________
|------------| | HumanResource |
|+name |<-------|_______________|
|+ssn | |etc...
|+address |
|etc... |
In this application there are several entities that have several different roles in the system. Without looking at the database this model looks and works fine in code. I fear that problems might arise WRT concurrency seeing that I have one table that has the GUID for nearly every single object in the system. BaseEntity's table will not be updated very frequently, it will be read an order of magnitude more often than updated.
Imagine that there is an exhaustive hierarchy of roles and value classes beneath BaseRole. A good example of this would be Chris Marshall's approach in chapter 4 of "Enterprise Modeling with UML".
Will the SQL that hibernate generates cause me problems using this approach?