ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Yee <r...@cruzio.com>
Subject Re: OnJava article
Date Thu, 03 Feb 2005 15:00:59 GMT
Mike,
According to the JavaDocs for the insert method:

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.

Parameters:
id - The name of the statement to execute.
parameterObject - The parameter object (e.g. JavaBean, Map, XML etc.).
Returns:
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.
-Richard


At 05:21 AM 2/3/2005, you wrote:

>Overall, I think it's a really good article. But one question about this 
>example...
>public void contactInsert() throws SQLException, IOException { 
>sqlMap.startTransaction(); try { sqlMap.startTransaction(); Contact 
>contact = new Contact(); contact.setContactId(3); 
>contact.setFirstName("John"); contact.setLastName("Doe"); 
>sqlMap.insert("insertContact",contact); sqlMap.commitTransaction(); } 
>finally{ sqlMap.endTransaction(); } }
>Inside of our Java code, we create a Contact object, populate its values, 
>and then call sqlMap.insert(), passing the name of the query that we want 
>to execute and the Contact. This method will insert the new contact and 
>return the primary key of the newly inserted contact. Is that last 
>sentence true? I am using <selectKey> now.
>Mike
>
>
>Do you Yahoo!?
>Yahoo! Search presents - 
><http://us.rd.yahoo.com/evt=30648/*http://movies.yahoo.com/movies/feature/jibjabinaugural.html>Jib

>Jab's 'Second Term'

Mime
View raw message