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 Rahul Saluja <ra...@vnl.in> on 2009/02/12 16:25:55 UTC

What does Insert method return

Hello Everyone,

Can anyone tell me what exactly does sqlmapclient.insert method return I know it returns an object but does it returns the object of selectkey means say in following example

<selectKey keyProperty="generatedSequenceId_0" resultClass="int">
      SELECT currval('MSCPerfCntrTrunk_seq')
    </selectKey>

Does it return an Integer Object containing an sequence value generated by my insert statement
or

does it return the actual Object which was just inserted with the  generatedSequenceId_0 field assigned the generated sequence number.


Eagerly Looking forward to your response.

Regards
Rahul Saluja
The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

RE: What does Insert method return

Posted by Rahul Saluja <ra...@vnl.in>.
Please help me ........................


-----Original Message-----
From: Rahul Saluja [mailto:rahul.saluja@vnl.in]
Sent: Thursday, February 12, 2009 9:17 PM
To: user-java@ibatis.apache.org; larry.meadors@gmail.com
Subject: RE: What does Insert method return

Hi Larry,

No I haven't run it , the problem is I  haven't got a test bed to run it and I am running short on time to actually create one. I know I am asking for baked cake but seriously I have no option as of now that's why I posted on forum otherwise I would not have done so.

I would be glad if you can clear my confusion.

Regards
Rahul Saluja

-----Original Message-----
From: Larry Meadors [mailto:larry.meadors@gmail.com]
Sent: Thursday, February 12, 2009 9:16 PM
To: user-java@ibatis.apache.org
Subject: Re: What does Insert method return

Did you run it to see?

Larry
The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.
The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

RE: What does Insert method return

Posted by Rahul Saluja <ra...@vnl.in>.
Hi Larry,

No I haven't run it , the problem is I  haven't got a test bed to run it and I am running short on time to actually create one. I know I am asking for baked cake but seriously I have no option as of now that's why I posted on forum otherwise I would not have done so.

I would be glad if you can clear my confusion.

Regards
Rahul Saluja

-----Original Message-----
From: Larry Meadors [mailto:larry.meadors@gmail.com]
Sent: Thursday, February 12, 2009 9:16 PM
To: user-java@ibatis.apache.org
Subject: Re: What does Insert method return

Did you run it to see?

Larry
The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

Re: What does Insert method return

Posted by Larry Meadors <la...@gmail.com>.
Did you run it to see?

Larry

RE: What does Insert method return

Posted by Rahul Saluja <ra...@vnl.in>.
Hi Sundar and Larry,

Really appreciate you taking out time and replying but my question still stands unanswered .

My question is the select key returns the generated sequence number in case of insert (that I know) ,so if I use the parameters class field as value to keyProperty attribute will that be set to in my parameters class's particular field i.e in my case generatedSequenceId_0 or will it be returned simply as an Integer object so in my code do I need to first call the getter method for generatedSequenceId_0 and then call type cast back to Integer Object and then call.intvalue on that object or what....... All I want is generated sequence to be available in java code.

sqlMap.startTransaction();
Object o = sqlMap.insert(a, newRecord);
Myobject mo = (MyObject)0;
Mo.getgeneratedSequenceId_0().intvalue();
sqlMap.startBatch();

Plsss help me I am confused.


Eagerly Looking forward to response.

Regards
Rahul Saluja




________________________________
From: Sundar Sankar [mailto:fatboysuns@gmail.com]
Sent: Thursday, February 12, 2009 9:42 PM
To: user-java@ibatis.apache.org
Subject: Re: What does Insert method return

Hi Rahul
check this website out http://ibatis.apache.org/docs/java/user/com/ibatis/sqlmap/client/SqlMapClient.html.
It seems to say that it will return the number of rows inserted.

Though I understand you have no test bed but I would still suggest you some how test it with a rollback enabled and see if the actual object or any other variety results do come back. I am not sure if you have spring in you app, But if you do, enabling a unit test is a piece of cake in Spring 2.5 +

-Sundar
On Thu, Feb 12, 2009 at 8:25 AM, Rahul Saluja <ra...@vnl.in>> wrote:

Hello Everyone,



Can anyone tell me what exactly does sqlmapclient.insert method return I know it returns an object but does it returns the object of selectkey means say in following example



<selectKey keyProperty="generatedSequenceId_0" resultClass="int">

      SELECT currval('MSCPerfCntrTrunk_seq')

    </selectKey>



Does it return an Integer Object containing an sequence value generated by my insert statement

or



does it return the actual Object which was just inserted with the  generatedSequenceId_0 field assigned the generated sequence number.





Eagerly Looking forward to your response.



Regards

Rahul Saluja

The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.

Re: What does Insert method return

Posted by Larry Meadors <la...@gmail.com>.
>From http://ibatis.apache.org/docs/java/user/com/ibatis/sqlmap/client/SqlMapClient.html.

"Executes a mapped SQL INSERT statement. Insert is a bit different
from other update methods, as it provides facilities for returning the
primary key of the newly inserted row (rather than the effected rows).
This functionality is of course optional."

Larry

Re: What does Insert method return

Posted by Sundar Sankar <fa...@gmail.com>.
Hi Rahul
check this website out
http://ibatis.apache.org/docs/java/user/com/ibatis/sqlmap/client/SqlMapClient.html
.
It seems to say that it will return the number of rows inserted.

Though I understand you have no test bed but I would still suggest you some
how test it with a rollback enabled and see if the actual object or any
other variety results do come back. I am not sure if you have spring in you
app, But if you do, enabling a unit test is a piece of cake in Spring 2.5 +

-Sundar

On Thu, Feb 12, 2009 at 8:25 AM, Rahul Saluja <ra...@vnl.in> wrote:

>  Hello Everyone,
>
>
>
> Can anyone tell me what exactly does sqlmapclient.insert method return I
> know it returns an object but does it returns the object of selectkey means
> say in following example
>
>
>
> <selectKey keyProperty="generatedSequenceId_0" resultClass="int">
>
>       SELECT currval('MSCPerfCntrTrunk_seq')
>
>     </selectKey>
>
>
>
> Does it return an Integer Object containing an sequence value generated by
> my insert statement
>
> or
>
>
>
> does it return the actual Object which was just inserted with the  generatedSequenceId_0
> field assigned the generated sequence number.
>
>
>
>
>
> Eagerly Looking forward to your response.
>
>
>
> Regards
>
> Rahul Saluja
>
> The information contained in this e-mail is private & confidential and may also be legally privileged. If you are not the intended recipient, please notify us, preferably by e-mail, and do not read, copy or disclose the contents of this message to anyone.
>
>