ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Update / subquery
Date Sun, 29 May 2005 06:47:07 GMT
I'm not sure why you posted the resultMap since you do not reference
it nor can you use it with an update statement. Your update statement
would function perfectly fine in ibatis assuming your paramters
satisfy the database. Your database is complaining that your SQL is
borked. Do you have logging enabled so that you can see what sql
statement is being passed and it's parameters?


On 5/28/05, Lieven De Keyzer <lieven_dekeyzer@hotmail.com> wrote:
> This statement returns an SQLException, saying I got an error in my SQL
> query.
> I can't seem to find one, so my question is: Is this possible in Ibatis?
> <update id="updateAccount" parameterClass="account">
>     UPDATE account
>     SET email= #email#, first_name = #firstName#, last_name = #lastName#,
> password = #password#,  role_id = (SELECT role_id FROM role WHERE rolename =
> #role#)
>     WHERE username = #username#
>   </update>
>   <resultMap id="accountResult" class="account">
>     <result property="username" column="username"/>
>     <result property="email" column="email"/>
>     <result property="firstName" column="first_name"/>
>     <result property="lastName" column="last_name"/>
>     <result property="role" column="rolename"/>
>     <result property="password" column="password"/>
>     <result property="rootId" column="folder_id"/>
>   </resultMap>
> The error:
> Cause: java.sql.SQLException: You have an error in your SQL syntax. Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 'SELECT role_id FROM role WHERE rolename = 'admin')

View raw message