Even better, I found out that I can use "Table per concrete class" with explicit polimorphism (opposed to implicit polimorphisms, as was with the <any> mapping), which is the nearly the same, but seems to be better, since it shares the ID through the subclasses tables, and therefore avoid to use a 'discriminator' column for telling which table to query.
Read about this here:
http://www.hibernate.org/hib_docs/v3...bleperconcrete
You can even define the super-class as abstract, and this effectively eliminates the need for a common table, and is very very similar to our proposed approach (one table for each object with implicit polimorphism through <any> mapping), the only difference is that instead of using a discriminator value for looking up the object (which allows us to know the table to query in advance), they use a 'shared' ID, where an ID is unique across the N tables, and therefore the ID itself defines the linked object.
Advantages:
* Simpler approach, no discriminator column
* full hibernate support (no limitations as with the <any> mapping, which limits several hibernate features as Polymorphic joins and Outer join fetching)
Disadvantages
* Performances (will have to query across the N involved tables I guess)
* Shared ID (which is less optimal than a proper separate ID for each table)
I'm now wondering if the fact that the DB will need to look for the needed IDs in three different tables (at least that's what I think), not knowing in advance which contains it, adds a lot of performance overhead to the join operations... will have to do some tests about it.
Anyone has experience regarding association to an interface (as my case) and the best way to map this? Implicit polimorphism with <any> mapping or explicit polimorphism with <union-subclass>?
Thanks again for any answer.