Quote:
While hibernate is primarily designed for hierarchy, it appears that you want to "re-use" the tables instead of them having any kind of hierarchy.
It's more what I need than what I want.
Quote:
Another approach that is definitely worth trying is related to using single table per class hierarchy,
For review targets? That would imply having the 80% of the app inside a table, most of it nulled out. It would be difficult to impose a hierarchy just for the review stuff, that's so for the java side, and no need to say that it's a no-no for the hibernate side.
Quote:
Since you have so many tables, having multiple foreign keys between same columns will affect performance of app as well as db, which must have
There should be no FK at all. Just targetId/targetKind to define the join condition. No FK constraints, that's for sure.
Quote:
occured to you. My feeling is that your design is not fully consistent. Different mappings tell hibernate you want to distinguish so it will give you different FKs, thats there in stone.
It's the simplest design I've worked out for this situation. It's a common pattern also (the pseudo id/discriminator fk), although it goes to some extent against database purisms. I just need to review lots of things, that's a functional requirement. I cannot impose a hierarchy to 80% of the entire app just for review purposes, that's somewhat of a design requirement, to say so. So my reviews just target Objects, well, ReviewTargets, which is more or less of a marker interface, just following a bit of programming by intention here. The only problem I find is the difficult of mapping the design and, of course, that I have to give up the possibility of having target FK constraints, which is a tradeoff I will be happy to take just in case hibernate let me do it.
Thank you.
Cheers,
Carlos