HeWhoSleepPrograms
HeWhoSleepPrograms

Reputation: 35

NHibernate mapping change delete command for object

Hi I would like to know how i can change manually change the default sql command to delete an object in the nhibernate mapping file. I want to use sevral delete commands at the same time, all using the id, how will I go about that?

Upvotes: 1

Views: 483

Answers (1)

Merlyn Morgan-Graham
Merlyn Morgan-Graham

Reputation: 59111

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querysql.html#querysql-cud

Hibernate3 can use custom SQL statements for create, update, and delete operations. The class and collection persisters in Hibernate already contain a set of configuration time generated strings (insertsql, deletesql, updatesql etc.). The mapping tags <sql-insert>, <sql-delete>, and <sql-update> override these strings:

<class name="Person">
    <id name="id">
        <generator class="increment"/>
    </id>
    <property name="name" not-null="true"/>
    <sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
</class>

Upvotes: 1

Related Questions