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 18:29:13 GMT
Hi Rick,

yes that was one of the typos in my earlier email, but I have corrected that
among other stuff (embarassing)!! My last email was also copy paste from my
sqlmap and does not have that issue... My question is about the syntax to
access a an attribute of an object that is passed as a value of map.

Thanks,
Anoop


On Tue, Aug 25, 2009 at 2:16 PM, Rick <rickcr@gmail.com> wrote:

> Was that copy and paste? I think you want "new.divisionName" now
> "newdivisionName" (assuming "new" is the key)
>
>
> On Tue, Aug 25, 2009 at 11: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
>>>> >
>>>>
>>>
>>>
>>
>
>
> --
> Rick R
>

Mime
View raw message