Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.1.7
Mapping documents:N/A
Code between sessionFactory.openSession() and session.close():N/A
Full stack trace of any exception that occurs:N/A
Name and version of the database you are using:MySQL 4.0.21
The generated SQL (show_sql=true):N/A
Debug level Hibernate log excerpt:N/A
---------------
Hi,
I have a question about the use of interfaces as described in the article "Getting Parents and Children to Play Nice" found on the hibernate site at:
http://www.hibernate.org/209.html.
In this example, they show using an interface "GenericJob" as the type for a Set property, which is what I also want to do. However, in the example, they specify the class in the one-to-many as an implementor of that interface named "ChildJobClass", and it's mentioned later that the table-per-subclass polymorphism strategy is used between the interface and implementors. The example seems to imply that only one class that implements that "GenericJob" interface can be inserted into this set, as that single class is specified in the one-to-many element.
I want to be able to do something similar, but I want to be able to insert any of several different classes that implement my interface into the set and have the set be able to contain any assorted group of classes that implement the interface. Is this possible? Also, is it *necessary* to use the table-per-subclass polymorphism strategy, or could another strategy be used? I've been trying to make this work with a many-to-many implemented as suggested in HIA as 2 one-to-many/many-to-one relationships to an intervening entity class but was getting strange results so I've decide to just see if I can implement a simple Set first. If hibernate doesn't support putting several different classes that implement an interface into a Set I'd like to find out before I waste a bunch of time trying to make it work. I can't find anything that addresses this directly, but can this be done? If so, how? I was thinking that I could specify the interface class in the one-to-many element in the parent's hbm file but would hibernate know what implementing class it was dealing with at runtime in that case via reflection? I'm going to try this but I have this feeling I'm missing something here, any help would be appreciated!
Thanks in advance!!
-=j=-