Hi,
I'm currently trying to map this kind of relations:
Computer - 1 -------------- N - InstalledSoftware
Computer - 1 -------------- N - InstallableSoftware
Computer - 1 -------------- N - EquivalentSoftware
In fact such relations are equivalent to the next one:
Computer - 1 -------------- N - software
where sofware is the generic entity for (InstalledSoftware,InstallableSoftware,EquivalentSoftware).
These 3 specifics entities all have the same attributes...
The only way I find to map this relation is to add a discriminator
column in the sofware table:
TYPE=I for Installed
TYPE=A for installable
TYPE=E for Equivalent...
and declaring a OneToMany relation between Computer and software... and finally implementing methods like:
Code:
Collection<Software> getAllinstallableSoftwares() {
List<Software> result = new ArrayList <Software>();
for (Software s:getSoftwares() ){
if (s.getType.equals("A") ) result.add(s);
}
return result;
}
I'm not sure this the best solution...
any ideas are welcome ;-)
(I'm interested in hibernate solution too)