Link to home
Get AccessLog in
Avatar of gdkinney_2

asked on

In Hibernate can a class attribute in a list tag in a .hbm file reference a Java Interface instead of a concrete class?

I have a Project.hbm file that contains a "list" tag as follows:    
<list name="munitions" table="project_munition" cascade="all">
            <key column="project_id"/>
            <list-index column="list_idx"/>
            <many-to-many column="munition_id"

SimpleShapedChargeMunition is a concrete class that has no parent class but implements an Interface called  So this creates an association table called project_munition that just contains project ids and munition ids.  I have created a new class called KEMunition that also implements the Munition interface.  I want to associate the KEMunitions to projects as well using the same association table.  I tried to change the class attribute reference in the list tag to use the Munition interface that they both implement but I got an error when I ran the database script.  Is there a way I can use the above association table to associate projects to either munition type?

Thank You
Avatar of gdkinney_2


Avatar of malfunction84
Flag of United States of America image

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access