Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.0
Mapping documents:
<class name="recipe.Recipe" table="recipes">
<id name="id" column="ID">
<generator class="identity"/>
</id>
<property name="name" column="recipe_name" />
<set name="tags" cascade="all,delete-orphan" inverse="true">
<key column="recipe_id" not-null="true" />
<one-to-many class="recipe.Tag" />
</set>
</class>
<class name="com.familyoven.recipe.Tag" table="recipes_tags">
<id name="id" column="id">
<generator class="identity"/>
</id>
<many-to-one name="recipe" foreign-key="recipe_id" column="recipe_id" class="recipe.Recipe"/>
<property name="name" column="name" />
</class>
Code between sessionFactory.openSession() and session.close():
recipe.getTags().clear();
Full stack trace of any exception that occurs:
Name and version of the database you are using:
MySQL 5.0
The generated SQL (show_sql=true):
delete from recipes_tags where id=?
delete from recipes_tags where id=?
delete from recipes_tags where id=?
The problem is, that hibernate issues 3 delete statements instead of one statement based on the foreign key. IE:
delete from recipes_tags where
recipe_id=?
what can I do to make it issue one statement.