Larry
<!--
Can't use 'useGeneratedKeys="true" keyProperty="categoryID"' here because it does not work with 'ON DUPLICATE KEY UPDATE'
-->
<insert id="insertObject" parameterType="com.poplar.db.beans.dictionaries.Category">
/* dictionaries.Category.insertObject */
INSERT INTO categories
(category_name)
VALUES (#{categoryName})
ON DUPLICATE KEY UPDATE
category_id=LAST_INSERT_ID(category_id);
<selectKey resultType="Integer" keyProperty="categoryID" order="AFTER">
SELECT LAST_INSERT_ID();
</selectKey>
</insert>
<insert id="insertObject" parameterType="com.poplar.db.beans.channels.Channel" useGeneratedKeys="true" keyProperty="channelID">
/* channels.Channel.insertObject */
INSERT INTO channels
(user_key,
title,
description)
VALUES (UNHEX(#{userKey}),
#{title},
#{description,jdbcType=VARCHAR}})
<!--
<selectKey resultType="Integer" keyProperty="channelID" order="AFTER">
SELECT LAST_INSERT_ID();
</selectKey>
-->
</insert>
François
--
Sent from my mobile device
If you must have the key returned, then you will need to write your
own method that extracts the key from the parameter object and returns
it.
Jeff Butler
It just doesn't work that way.
The parameter object (the Device passed in) will have it's "deviceId"
property set.
Larry