Well first of all, this is my first post. So hi! Second of all, following full disclosure, this is cross-posted on stackoverflow however there were a lack of answers so I decided to reach out further.
Given the following Java class:
I would like to be able to use generics to have type safety, while still utilizing hibernate to do my persistence. By default, I am (obviously) receiving an exception of ...has an unbound type and no explicit target entity. Resolve this Generic usage issue or set an explicit target attribute (eg @OneToMany(target=) or use an explicit @Type. What I'd like to do is specify to hibernate what classes are valid there, such as multiple annotations of the targetEntity attribute. The reason I'd like this is anything can go into that Box, not just specific things out of an inheritance hierarchy. An example would be if I have an abstract class Parent and two children ChildA and ChildB. Not only would I want ChildA and ChildB as possible members, I would also like to fill the Box with String.
Please ask me any questions if I am not making myself clear. I'm not even sure if what I'm asking is possible, but the first comment on S.O made a lot of sense as to what I wanted the final table to look like:
"How do you expect Hibernate to build such a generic object? It seems like you would have to have some sort of discriminator column and identify all the possible objects that could be used. But, I don't know if that's possible here."
Basically it would be nice to wind up with a discriminator column in the Box table, along with the foreign key of the given member in another column. (Much like how hibernate by default handles abstract classes with Entity declaration on the parent)