ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burke.Kevin" <Kevin.Bu...@cic.gc.ca>
Subject RE: What does Insert method return
Date Thu, 12 Feb 2009 17:54:40 GMT
I believe that your parameterMap (or parameterClass) object as defined
in the parameterClass attribute of the <insert> statement in your sqlMap
file, will have the attribute that matched the keyProperty set, so when
the insert() method returns, in your example below, newRecord will have
the matching attribute set by the iBatis call.  If "newRecord" has an
attribute called generatedSequenceId_0, and you specify this as your
keyProperty value (i.e. <selectKey resultClass="int"
keyProperty="generatedSequenceId_0">), then the setter is called on the
parameterClass when the keyProperty is derived.
 
Does this answer your question?
 
-Kevin
 
 
-----Original Message-----
From: Rahul Saluja [mailto:rahul.saluja@vnl.in] 
Sent: February 12, 2009 11:23 AM
To: user-java@ibatis.apache.org
Subject: RE: What does Insert method return



	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/SqlMapC
lient.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
<rahul.saluja@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.


Mime
View raw message