You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Anoop kumar V <an...@gmail.com> on 2009/08/23 05:54:26 UTC
Newbie question: Update table that has no key / id
Hi,
I am facing an issue updating a table that is part of a crappy datamodel.
The table has no primary key. It has 3 columns user, region and division.
My issue is when a user wants to modify a particular record, I am not sure
how to pass the parameters...
<update id="updateUserApprover" parameterClass="ad.UserApprover">
update user_approvers set region_name = #region:VARCHAR#,
division_name = #division:VARCHAR#,
where user = #user:VARCHAR#
and region = #region:VARCHAR#
and division=#division:VARCHAR#
</update>
I know the above is hopelessly wrong, the where clause parameters is the
same as the update values and this will never find the record and so will
not update anything.
I think there is a unique constraint or composite key set up for all 3
columns. I am using Oracle in production and mysql on my laptop if that
makes a difference. Would using rownum or something make some sort of
difference?
Thanks,
Anoop
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
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 <an...@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 <na...@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 <an...@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 <an...@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<an...@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 <la...@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
>>>>> >
>>>>>
>>>>
>>>>
>>>
>>
>
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
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 <na...@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 <an...@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 <an...@gmail.com>wrote:
>>
>>> I understand. Thank you very much.
>>>
>>> -Anoop
>>>
>>>
>>>
>>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <la...@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<an...@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 <la...@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
>>>> >
>>>>
>>>
>>>
>>
>
Re: Newbie question: Update table that has no key / id
Posted by Nathan Maves <na...@gmail.com>.
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 <an...@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 <an...@gmail.com>wrote:
>
>> I understand. Thank you very much.
>>
>> -Anoop
>>
>>
>>
>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <la...@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<an...@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 <la...@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
>>> >
>>>
>>
>>
>
Re: Newbie question: Update table that has no key / id
Posted by Nathan Maves <na...@gmail.com>.
Now is the time to turn on logging and see just what sql is being produced.
set java.sql=DEBUG in your logging configuration.
On Tue, Aug 25, 2009 at 12:29 PM, Anoop kumar V <an...@gmail.com>wrote:
> 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 <ri...@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 <an...@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 <an...@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<an...@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 <la...@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
>>
>
>
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
Yes - true, but in this case I would have had to use something like p6spy.
Also I am integrating iBatis with a COTS application that does not use log4j
or something similar.
I could not find much searching for an alternative configuration (without
log4j) to log ibatis sql statements etc..
Thanks,
Anoop
On Tue, Aug 25, 2009 at 3:54 PM, Rick <ri...@gmail.com> wrote:
> Definitely do what Nathan said and output the generated sql. That will let
> you catch these issues much sooner.
>
>
>
> On Tue, Aug 25, 2009 at 3:25 PM, Anoop kumar V <an...@gmail.com>wrote:
>
>> Yes - that was it. It is all working great now. not a single issue with
>> this..
>>
>> thank you so much for all your help and I know I just needed to be more
>> careful with my typos...
>>
>> Thanks,
>> Anoop
>>
>>
>>
>> On Tue, Aug 25, 2009 at 3:18 PM, Anoop kumar V <an...@gmail.com>wrote:
>>
>>> Oops - that is a big typo. I really need to be more careful. Let me set
>>> that right and test again.
>>>
>>> Thanks,
>>> Anoop
>>>
>>>
>>>
>>> On Tue, Aug 25, 2009 at 3:02 PM, Rick <ri...@gmail.com> wrote:
>>>
>>>> no clue what your table looks like but this doesn't seem right: iamsId
>>>> for both?
>>>>
>>>> where
>>>> iams_id = #old.iamsId:VARCHAR#
>>>> //....
>>>> and isactive=#old.iamsId:VARCHAR#
>>>>
>>>>
>>>>
>>>> On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <an...@gmail.com>wrote:
>>>>
>>>>> 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 <ri...@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 <la...@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
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Rick R
>>>>
>>>
>>>
>>
>
>
> --
> Rick R
>
Re: Newbie question: Update table that has no key / id
Posted by Rick <ri...@gmail.com>.
Definitely do what Nathan said and output the generated sql. That will let
you catch these issues much sooner.
On Tue, Aug 25, 2009 at 3:25 PM, Anoop kumar V <an...@gmail.com>wrote:
> Yes - that was it. It is all working great now. not a single issue with
> this..
>
> thank you so much for all your help and I know I just needed to be more
> careful with my typos...
>
> Thanks,
> Anoop
>
>
>
> On Tue, Aug 25, 2009 at 3:18 PM, Anoop kumar V <an...@gmail.com>wrote:
>
>> Oops - that is a big typo. I really need to be more careful. Let me set
>> that right and test again.
>>
>> Thanks,
>> Anoop
>>
>>
>>
>> On Tue, Aug 25, 2009 at 3:02 PM, Rick <ri...@gmail.com> wrote:
>>
>>> no clue what your table looks like but this doesn't seem right: iamsId
>>> for both?
>>>
>>> where
>>> iams_id = #old.iamsId:VARCHAR#
>>> //....
>>> and isactive=#old.iamsId:VARCHAR#
>>>
>>>
>>>
>>> On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <an...@gmail.com>wrote:
>>>
>>>> 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 <ri...@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 <la...@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
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Rick R
>>>
>>
>>
>
--
Rick R
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
Yes - that was it. It is all working great now. not a single issue with
this..
thank you so much for all your help and I know I just needed to be more
careful with my typos...
Thanks,
Anoop
On Tue, Aug 25, 2009 at 3:18 PM, Anoop kumar V <an...@gmail.com>wrote:
> Oops - that is a big typo. I really need to be more careful. Let me set
> that right and test again.
>
> Thanks,
> Anoop
>
>
>
> On Tue, Aug 25, 2009 at 3:02 PM, Rick <ri...@gmail.com> wrote:
>
>> no clue what your table looks like but this doesn't seem right: iamsId for
>> both?
>>
>> where
>> iams_id = #old.iamsId:VARCHAR#
>> //....
>> and isactive=#old.iamsId:VARCHAR#
>>
>>
>>
>> On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <an...@gmail.com>wrote:
>>
>>> 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 <ri...@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 <an...@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<an...@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 <la...@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
>>>>
>>>
>>>
>>
>>
>> --
>> Rick R
>>
>
>
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
Oops - that is a big typo. I really need to be more careful. Let me set that
right and test again.
Thanks,
Anoop
On Tue, Aug 25, 2009 at 3:02 PM, Rick <ri...@gmail.com> wrote:
> no clue what your table looks like but this doesn't seem right: iamsId for
> both?
>
> where
> iams_id = #old.iamsId:VARCHAR#
> //....
> and isactive=#old.iamsId:VARCHAR#
>
>
>
> On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <an...@gmail.com>wrote:
>
>> 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 <ri...@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 <an...@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 <an...@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<an...@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 <la...@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
>>>
>>
>>
>
>
> --
> Rick R
>
Re: Newbie question: Update table that has no key / id
Posted by Rick <ri...@gmail.com>.
no clue what your table looks like but this doesn't seem right: iamsId for
both?
where
iams_id = #old.iamsId:VARCHAR#
//....
and isactive=#old.iamsId:VARCHAR#
On Tue, Aug 25, 2009 at 2:29 PM, Anoop kumar V <an...@gmail.com>wrote:
> 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 <ri...@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 <an...@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 <an...@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<an...@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 <la...@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
>>
>
>
--
Rick R
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
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 <ri...@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 <an...@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 <an...@gmail.com>wrote:
>>
>>> I understand. Thank you very much.
>>>
>>> -Anoop
>>>
>>>
>>>
>>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <la...@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<an...@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 <la...@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
>
Re: Newbie question: Update table that has no key / id
Posted by Rick <ri...@gmail.com>.
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 <an...@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 <an...@gmail.com>wrote:
>
>> I understand. Thank you very much.
>>
>> -Anoop
>>
>>
>>
>> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <la...@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<an...@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 <la...@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
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
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 <an...@gmail.com>wrote:
> I understand. Thank you very much.
>
> -Anoop
>
>
>
> On Mon, Aug 24, 2009 at 9:20 AM, Larry Meadors <la...@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<an...@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 <la...@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
>> >
>>
>
>
Re: Newbie question: Update table that has no key / id
Posted by Anoop kumar V <an...@gmail.com>.
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 <la...@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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org
Re: Newbie question: Update table that has no key / id
Posted by Larry Meadors <la...@gmail.com>.
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