views:

296

answers:

1

How to use native Sql for Insert and Update in Castle Active Record? There are sample for using Select query here http://www.castleproject.org/activerecord/documentation/trunk/usersguide/nativesql.html
But I can't find any sample for Update and Insert.

Update: Basically I am looking for a support for Update/Insert query like this.

<class name="Person">
    <id name="id">
        <generator class="increment"/>
    </id>
    <property name="name" not-null="true"/>
    <sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>
    <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>
    <sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
</class>
+1  A: 

AFAIK <sql-insert> et al. are not implemented in ActiveRecord. You could try implementing INHContributor to modify the NHibernate configuration and add those queries to the class mapping, but it won't be easy.

Even better would be implementing it and submitting a patch! For guidance, ask on the Castle developers google group.

Mauricio Scheffer