Hello,
I'm facing a strange problem with a one to many relation. I use a join table (see mapping file extract).
When I execute the test code (see appended code), it succesfully stores a recipe and a action. But the join table has no content.
Recipe subclasses the Action class with a union-subclass statement. The Query method persists calls saveOrUpdate from the generated session.
Any help is really appreciated as I searched about 2 hours and found nothing appropriate.
Thanks in advance
Regards
Guenther
Hibernate version:
3.1.3 deployed on Tomcat 6
Mapping documents:
Code:
<set name="actions" table="RECIPECONSISTOFACTION"
cascade="all">
<key column="RECIPE_ID" not-null="true" />
<many-to-many column="ACTION_ID" unique="true"
class="Action" />
</set>
Test case:Code:
/*
* create a new recipe
*/
Recipe recipe = new Recipe();
recipe.setName("Biscuit");
recipe.setDescription("A base recipe to create a small cake as base for wiped cream cakes.");
recipe.setImageLocation("pics/biscuit.jpg");
/*
* add a action
*/
Action action = new Action();
action.setName("Add Sugar");
action.setDescription("Add Sugar to the dough.");
recipe.addAction(action);
/*
* create a query and save the thing
*/
RecipeQuery query = new RecipeQuery();
Session session = HibernateUtil.getSessionFactory().openSession();
query.setSession(session);
query.persist(recipe);
session.close();