Add a custom sql-insert statement that insert base on other class values as parameters

12 views
Skip to first unread message

Ken Hu

unread,
Jun 10, 2011, 6:00:30 AM6/10/11
to nhusers
Add a custom sql-insert statement that insert base on other class
values as parameters. Is there any way and if there is kindly inform
us.

Fabio Maulo

unread,
Jun 11, 2011, 2:11:09 PM6/11/11
to nhu...@googlegroups.com
For each class/collection you have: loader, sql-insert, sql-update, sql-delete

<class name="Person" table="PERSON">
<id name="Id" unsaved-value="0" column="PERID">
<generator class="increment"/>
</id>
<property name="Name" not-null="true" column="NAME"/>
<loader query-ref="person"/>
<sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert>
<sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
<sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
</class>

<sql-query name="person">
<return alias="p" class="Person" lock-mode="upgrade"/>
SELECT NAME AS {p.Name}, PERID AS {p.Id} FROM PERSON WHERE PERID=? FOR UPDATE
</sql-query>

Ken Hu

unread,
Jun 12, 2011, 10:56:46 PM6/12/11
to nhusers
Hi All,

Thanks for it , now my second question is if i have 2 classes and the
relationship is indicated below:

ImageProcessingTemplate (1) -> (M) PageProcessing

And for efficiency, I kept all in 1 table. Which means the design of
the table is something like the below:

ID | ImageProcessingTemplateID

Therefore the ID is unique while image processing templateID may be
duplicated therefore in my mapping how can i map a sub class ID as a
paremeter in my parent custom sql insertion statement ?
Reply all
Reply to author
Forward
0 new messages