ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anoop kumar V <anoopkum...@gmail.com>
Subject Re: Newbie question: Update table that has no key / id
Date Tue, 25 Aug 2009 17:49:10 GMT
Ok - now I do not get any errors in any logs, but the update does not seem
to be trigerring. Can someone please confirm that the syntax in my sqlmap is
correct?

<update id="updateUserApprover" parameterClass="java.util.Map">
    update user_approvers set
            iams_id = #new.iamsId:VARCHAR#,
            region_name = #new.regionName:VARCHAR#,
            division_name = #new.divisionName:VARCHAR#,
            isactive = #new.isActive:VARCHAR#
    where
            iams_id = #old.iamsId:VARCHAR#
            and region_name = #old.regionName:VARCHAR#
            and division_name=#old.divisionName:VARCHAR#
            and isactive=#old.iamsId:VARCHAR#
  </update>

new and old are keys in the map. They each point to a UserApprover object
which is a bean. The UserApprover object has 4 attributes: iamsId,
regionName, divisionName and isActive. Is my syntax correct? #new.iamsId#
should point to the iamsId attribute in the userapprover object
corresponding to the "new" key. I do not get any errors, but nothing seems
to happen. Please help

Thanks,
Anoop


On Tue, Aug 25, 2009 at 11:50 AM, Anoop kumar V <anoopkumarv@gmail.com>wrote:

> Yes - thank you Nathan. I realize I have quite a few typos in my sql... Let
> me get all those cleared before reaching out again
> for help. Appreciate your help.
>
> Thanks,
> Anoop
>
>
>
> On Tue, Aug 25, 2009 at 11:48 AM, Nathan Maves <nathan.maves@gmail.com>wrote:
>
>> Anoop,
>>
>> What you are getting is a SQL exception.  This means that ibatis has
>> already done its job.  I would guess that your issue is with the reuse of
>> the word "set" before the region_name column.
>>
>> nathan
>>
>>
>> On Tue, Aug 25, 2009 at 9:40 AM, Anoop kumar V <anoopkumarv@gmail.com>wrote:
>>
>>> Hi Larry,
>>>
>>> Was wondering if you could help me clarify one thing more...
>>>
>>> I have my sqlmap as below:
>>>
>>> <update id="updateUserApprover" parameterClass="java.util.Map">
>>>     update user_approvers
>>>             set iams_id = #new.iamsId:VARCHAR#,
>>>             set region_name = #new.regionName:VARCHAR#,
>>>             division_name = #newdivisionName:VARCHAR#,
>>>             isactive = #new.isActive:VARCHAR#
>>>     where iams_id = #old.iamsId:VARCHAR#
>>>     and region_name = #old.regionName:VARCHAR#
>>>     and division_name=#old.divisionName:VARCHAR#
>>>     and isactive=#old.iamsId:VARCHAR#
>>>   </update>
>>>
>>> I am passing a map that has 2 objects which is coming from my bean, the
>>> keys are "old" and "new" and each have a userApprover object as the value.
>>> Map<String, UserApprover> param = new HashMap<String, UserApprover>();
>>>
>>> So when I put: #new.iamsId:VARCHAR# will the sqlmap be able to understand
>>> that it needs to go inside the map and pull the property from the bean?
>>>
>>> I am getting the following error when I use it this way:
>>>
>>> 09/08/25 11:29:40 com.ibatis.common.jdbc.exception.NestedSQLException:
>>> --- The error occurred in sqlmap/userapprover_sqlMap.xml.
>>> --- The error occurred while applying a parameter map.
>>> --- Check the updateUserApprover-InlineParameterMap.
>>> --- Check the statement (update failed).
>>> --- Cause: java.sql.SQLException: ORA-01747: invalid user.table.column,
>>> table.column, or column specification
>>>
>>> The other way is that I can completely forget about my bean and just put
>>> everything into my map as <String, String>, but I dont think that is a
very
>>> nice thing to do... any suggestions please?
>>>
>>> Thanks,
>>> Anoop
>>>
>>>
>>> On Mon, Aug 24, 2009 at 10:02 AM, Anoop kumar V <anoopkumarv@gmail.com>wrote:
>>>
>>>> I understand. Thank you very much.
>>>>
>>>> -Anoop
>>>>
>>>>
>>>>
>>>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <larry.meadors@gmail.com
>>>> > wrote:
>>>>
>>>>> Not if those values can change.
>>>>>
>>>>> If they are immutable, then that makes it easier, because you can
>>>>> update based on them.
>>>>>
>>>>> Larry
>>>>>
>>>>>
>>>>> On Mon, Aug 24, 2009 at 7:10 AM, Anoop kumar V<anoopkumarv@gmail.com>
>>>>> wrote:
>>>>> > Thanks Larry. I think your suggestion will work, but I was hoping
>>>>> > there was an ibatis way of handling this - or that I could use the
>>>>> > database specific rownum or something similar.
>>>>> >
>>>>> > Would it make a big difference if the table had a composite key,
such
>>>>> > that no 2 rows have exactly the same column values?
>>>>> >
>>>>> > Thanks again,
>>>>> > Anoop
>>>>> >
>>>>> > On 8/23/09, Larry Meadors <larry.meadors@gmail.com> wrote:
>>>>> >> You can do it a few ways, I think I'd put the old values and
new
>>>>> >> values in a bean, then put those beans in a map and call them
"old"
>>>>> >> and "new".
>>>>> >>
>>>>> >> Pass that map to the update and change it to this:
>>>>> >>
>>>>> >>   <update id="updateUserApprover">
>>>>> >>     update user_approvers set region_name = #new.region:VARCHAR#,
>>>>> >>                       division_name = #new.division:VARCHAR#,
>>>>> >>     where user = #old.user:VARCHAR#
>>>>> >>     and region = #old.region:VARCHAR#
>>>>> >>     and division=#old.division:VARCHAR#
>>>>> >>   </update>
>>>>> >>
>>>>> >> Larry
>>>>> >>
>>>>> >>
>>>>> ---------------------------------------------------------------------
>>>>> >> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>>>> >> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>>> >>
>>>>> >>
>>>>> >
>>>>> >
>>>>> > --
>>>>> >
>>>>> > Thanks,
>>>>> > Anoop
>>>>> >
>>>>>
>>>>
>>>>
>>>
>>
>

Mime
View raw message