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 "Krishnamoorthi, Sruthi (Raytheon)" <Sr...@USPTO.GOV> on 2006/03/10 18:41:56 UTC
Urgent help required
The docs says
int rows = sqlMap.insert ("insertProduct", product);
returns a int value
When I code it ,the return value is object. I am not able to get the int return value. Please help me out.
Thanks,
Sruthi Krishnamoorthi
703-562-9732(Work)
537 A - (Raytheon) Location
Re: Urgent help required
Posted by Nathan Maves <Na...@Sun.COM>.
ouch the first line should read...
int rows = ((Integer)sqlMap.insert("insertProduct", product)).intValue
();
On Mar 10, 2006, at 10:51 AM, Nathan Maves wrote:
> Just use
>
> Integer rows = ((Integer)sqlMap.insert("insertProduct",
> product)).intValue();
>
> if you are using Java 1.5
>
> int rows = (Integer)sqlMap.insert("insertProduct", product);
>
> Nathan
>
>
> On Mar 10, 2006, at 10:41 AM, Krishnamoorthi, Sruthi (Raytheon) wrote:
>
>> The docs says
>>
>> int rows = sqlMap.insert (“insertProduct”, product);
>>
>> returns a int value
>>
>>
>> When I code it ,the return value is object. I am not able to get
>> the int return value. Please help me out.
>>
>>
>> Thanks,
>> Sruthi Krishnamoorthi
>> 703-562-9732(Work)
>> 537 A - (Raytheon) Location
>>
>>
>
Re: Urgent help required
Posted by Nathan Maves <Na...@Sun.COM>.
Just use
Integer rows = ((Integer)sqlMap.insert("insertProduct",
product)).intValue();
if you are using Java 1.5
int rows = (Integer)sqlMap.insert("insertProduct", product);
Nathan
On Mar 10, 2006, at 10:41 AM, Krishnamoorthi, Sruthi (Raytheon) wrote:
> The docs says
>
> int rows = sqlMap.insert (“insertProduct”, product);
>
> returns a int value
>
>
> When I code it ,the return value is object. I am not able to get
> the int return value. Please help me out.
>
>
> Thanks,
> Sruthi Krishnamoorthi
> 703-562-9732(Work)
> 537 A - (Raytheon) Location
>
>
Re: Urgent help required
Posted by Perry Nguyen <pf...@hanhuy.com>.
I don't count myself as often, but for a 1:M or M:M relationship, I will
often insert multiple rows in a statement.
However, I have no need of the updated row count nor retrieving the PK
for each entry (as they are keyed off of the other relationship).
Larry Meadors wrote:
> Am I missing something here...do people frequently insert multiple rows?
>
> Because I would guess that 99.999% of the time I insert one and only one row.
>
> Getting a 0 or 1 back is no more useful than an exception being thrown
> (or not being thrown).
>
> This is not going to be changed because of that and the fact that it
> would break the existing selectKey behavior unless we returned a List
> (..and would that be a list of generated keys, or 0s and 1s?).
>
> Larry
>
>
> On 3/12/06, Cornel Antohi <ca...@kepler-rominfo.com> wrote:
>> Hi,
>>
>> We experienced the same "strange" problem and we decided, until IBatis team
>> will implement the insert as in documentation, to use "update" option from
>> xml files with an INSERT sql query.
>>
>> Thank you,
>>
>> Cornel
Re: Urgent help required
Posted by Larry Meadors <lm...@apache.org>.
Am I missing something here...do people frequently insert multiple rows?
Because I would guess that 99.999% of the time I insert one and only one row.
Getting a 0 or 1 back is no more useful than an exception being thrown
(or not being thrown).
This is not going to be changed because of that and the fact that it
would break the existing selectKey behavior unless we returned a List
(..and would that be a list of generated keys, or 0s and 1s?).
Larry
On 3/12/06, Cornel Antohi <ca...@kepler-rominfo.com> wrote:
>
> Hi,
>
> We experienced the same "strange" problem and we decided, until IBatis team
> will implement the insert as in documentation, to use "update" option from
> xml files with an INSERT sql query.
>
> Thank you,
>
> Cornel
Re: Urgent help required
Posted by netsql <ne...@roomity.com>.
Most likely for "muti-insert" you want to use prepared statement (inside
a transaction), and I do so in Groovy (instead of iBatis, I use ibatis
for OLTP, Groovy for batch. Q: I wonder if people know why prepared
statement exists even. A: It's 1,000 times faster).
.V
Sven Boden wrote:
>So insert does not return the number
> of inserted rows. From the javadocs:
>
>
Re: Re: Urgent help required
Posted by Sven Boden <li...@pandora.be>.
In the meantime the open office document is changed to be in sync with
the actual iBATIS implementation. So insert does not return the number
of inserted rows. From the javadocs:
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.
The parameter object is generally used to supply the input data for the
INSERT values.
@param id The name of the statement to execute.
@param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
@return The primary key of the newly inserted row. This might be
automatically generated by the RDBMS, or selected from a sequence table
or other source.
@throws java.sql.SQLException If an error occurs.
Regards,
Sven
Cornel Antohi wrote:
>Hi,
>
>We experienced the same "strange" problem and we decided, until IBatis team will implement the insert as in documentation, to use "update" option from xml files with an INSERT sql query.
>
>Thank you,
>Cornel
> ----- Original Message -----
> From: Krishnamoorthi, Sruthi (Raytheon)
> To: user-java@ibatis.apache.org
> Sent: Friday, March 10, 2006 7:41 PM
> Subject: Urgent help required
>
>
> The docs says
>
> int rows = sqlMap.insert ("insertProduct", product);
>
> returns a int value
>
>
>
> When I code it ,the return value is object. I am not able to get the int return value. Please help me out.
>
>
> Thanks,
> Sruthi Krishnamoorthi
> 703-562-9732(Work)
> 537 A - (Raytheon) Location
>
>
>
>
Re: Urgent help required
Posted by Cornel Antohi <ca...@kepler-rominfo.com>.
Hi,
We experienced the same "strange" problem and we decided, until IBatis team will implement the insert as in documentation, to use "update" option from xml files with an INSERT sql query.
Thank you,
Cornel
----- Original Message -----
From: Krishnamoorthi, Sruthi (Raytheon)
To: user-java@ibatis.apache.org
Sent: Friday, March 10, 2006 7:41 PM
Subject: Urgent help required
The docs says
int rows = sqlMap.insert ("insertProduct", product);
returns a int value
When I code it ,the return value is object. I am not able to get the int return value. Please help me out.
Thanks,
Sruthi Krishnamoorthi
703-562-9732(Work)
537 A - (Raytheon) Location
Re: Urgent help required
Posted by Hu...@mcnichols.com.
Actually, what I have written does not take the place of a DAO layer per
say,,,
All that it does it completely turn it into an object database type layer,
without having to pass strings into the statements. It completely abstracts
you from Ibatis, is all, so you have a generic Datastore interface, with a
concrete factory that creates an instance of that implementation. Mine is
IbatisDataStore.java.
That way, instead of using
sqlMapClient.insert("insertPerson", arg1),, or whatever,,, you just have
DataStore.insert (Person );
Much cleaner, and better abstraction in my opinion. You clients, or
whatever have no idea about ibatis, or anything, which you could put in a
dao layer, whatever. We certainly over enginner things here. I worked a
little on the JDO spec and used Hibernate tons, I just hated having to pass
"function" names into the methods, when nobody else does this.
Hugh
"Larry Meadors"
<lmeadors@apache.
org> To
Sent by: user-java@ibatis.apache.org
larry.meadors@gma cc
il.com
Subject
Re: Urgent help required
03/10/2006 01:01
PM
Please respond to
user-java@ibatis.
apache.org
Do you mean using a DAO layer around iBATIS?
Larry
On 3/10/06, Hugh.Compton@mcnichols.com <Hu...@mcnichols.com> wrote:
> You would actually prefer to receive the object back right? just that it
is
> not null tells you that something was inserted. WIth the object being
> returned you can see additional things that your SQL might have done,
like
> if you are calling a stored proc, or if you are using the <selectKey>
proc
> in your <insert> then that field in you object would have the value in it
> too......
>
> Beter in my opinion....
>
>
> Anyone ever thought of writing an abstraction layer with Ibatus? i.e.
>
>
> /////////////////////////////////////
> DataStore ds = new DatastoreFactory.getDataStore(Widget.class);
> Widget w = new Widget();
> ...
>
> Collection c = ds.findAll( )
> Widget w1 = ds.find( new Object[] { new String( " WHERE PK = 2 ") } )
>
> ds.insert( w );
> w.modifySomething();
> ds.update( w );
> ds.delete( w );
> //////////////////
>
>
> I got one of these written, works slick. The reason why, only thing I
> REALLY hate about Ibatis is having to pass the string names into the
> update, inserts, etc.
>
> NEXT::
> I hate the SQL grammer coupling I introduced on the finder methods. This
> actually causes you to have to KNOW column names, which is not ideal. I
am
> going to generate a EL language that will parse through the xml files and
> get the column - > property names so you can do this findAll("
> accountBalance > 20.00 "), (where accountBalance is the actuall POJO
> property name, NOT the column name.....
>
> Any takers / thoughts?
>
>
> Hugh Compton
>
>
>
>
>
> "Krishnamoorthi,
> Sruthi
> (Raytheon)"
To
> <Sruthi.Krishnamo user-java@ibatis.apache.org
> orthi@USPTO.GOV>
cc
>
> 03/10/2006 12:41
Subject
> PM Urgent help required
>
>
> Please respond to
> user-java@ibatis.
> apache.org
>
>
>
>
>
>
> The docs says
>
>
> int rows = sqlMap.insert ("insertProduct", product);
>
>
> returns a int value
>
>
>
>
>
> When I code it ,the return value is object. I am not able to get the int
> return value. Please help me out.
>
>
>
>
>
> Thanks,
> Sruthi Krishnamoorthi
> 703-562-9732(Work)
> 537 A - (Raytheon) Location
>
>
>
>
>
Re: Urgent help required
Posted by Larry Meadors <lm...@apache.org>.
Do you mean using a DAO layer around iBATIS?
Larry
On 3/10/06, Hugh.Compton@mcnichols.com <Hu...@mcnichols.com> wrote:
> You would actually prefer to receive the object back right? just that it is
> not null tells you that something was inserted. WIth the object being
> returned you can see additional things that your SQL might have done, like
> if you are calling a stored proc, or if you are using the <selectKey> proc
> in your <insert> then that field in you object would have the value in it
> too......
>
> Beter in my opinion....
>
>
> Anyone ever thought of writing an abstraction layer with Ibatus? i.e.
>
>
> /////////////////////////////////////
> DataStore ds = new DatastoreFactory.getDataStore(Widget.class);
> Widget w = new Widget();
> ...
>
> Collection c = ds.findAll( )
> Widget w1 = ds.find( new Object[] { new String( " WHERE PK = 2 ") } )
>
> ds.insert( w );
> w.modifySomething();
> ds.update( w );
> ds.delete( w );
> //////////////////
>
>
> I got one of these written, works slick. The reason why, only thing I
> REALLY hate about Ibatis is having to pass the string names into the
> update, inserts, etc.
>
> NEXT::
> I hate the SQL grammer coupling I introduced on the finder methods. This
> actually causes you to have to KNOW column names, which is not ideal. I am
> going to generate a EL language that will parse through the xml files and
> get the column - > property names so you can do this findAll("
> accountBalance > 20.00 "), (where accountBalance is the actuall POJO
> property name, NOT the column name.....
>
> Any takers / thoughts?
>
>
> Hugh Compton
>
>
>
>
>
> "Krishnamoorthi,
> Sruthi
> (Raytheon)" To
> <Sruthi.Krishnamo user-java@ibatis.apache.org
> orthi@USPTO.GOV> cc
>
> 03/10/2006 12:41 Subject
> PM Urgent help required
>
>
> Please respond to
> user-java@ibatis.
> apache.org
>
>
>
>
>
>
> The docs says
>
>
> int rows = sqlMap.insert ("insertProduct", product);
>
>
> returns a int value
>
>
>
>
>
> When I code it ,the return value is object. I am not able to get the int
> return value. Please help me out.
>
>
>
>
>
> Thanks,
> Sruthi Krishnamoorthi
> 703-562-9732(Work)
> 537 A - (Raytheon) Location
>
>
>
>
>
Re: Urgent help required
Posted by Hu...@mcnichols.com.
You would actually prefer to receive the object back right? just that it is
not null tells you that something was inserted. WIth the object being
returned you can see additional things that your SQL might have done, like
if you are calling a stored proc, or if you are using the <selectKey> proc
in your <insert> then that field in you object would have the value in it
too......
Beter in my opinion....
Anyone ever thought of writing an abstraction layer with Ibatus? i.e.
/////////////////////////////////////
DataStore ds = new DatastoreFactory.getDataStore(Widget.class);
Widget w = new Widget();
...
Collection c = ds.findAll( )
Widget w1 = ds.find( new Object[] { new String( " WHERE PK = 2 ") } )
ds.insert( w );
w.modifySomething();
ds.update( w );
ds.delete( w );
//////////////////
I got one of these written, works slick. The reason why, only thing I
REALLY hate about Ibatis is having to pass the string names into the
update, inserts, etc.
NEXT::
I hate the SQL grammer coupling I introduced on the finder methods. This
actually causes you to have to KNOW column names, which is not ideal. I am
going to generate a EL language that will parse through the xml files and
get the column - > property names so you can do this findAll("
accountBalance > 20.00 "), (where accountBalance is the actuall POJO
property name, NOT the column name.....
Any takers / thoughts?
Hugh Compton
"Krishnamoorthi,
Sruthi
(Raytheon)" To
<Sruthi.Krishnamo user-java@ibatis.apache.org
orthi@USPTO.GOV> cc
03/10/2006 12:41 Subject
PM Urgent help required
Please respond to
user-java@ibatis.
apache.org
The docs says
int rows = sqlMap.insert (“insertProduct”, product);
returns a int value
When I code it ,the return value is object. I am not able to get the int
return value. Please help me out.
Thanks,
Sruthi Krishnamoorthi
703-562-9732(Work)
537 A - (Raytheon) Location