ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dwight Galloway" <dsgal...@utah.gov>
Subject Auto-generated keys using Sybase
Date Mon, 13 Jun 2005 22:55:18 GMT
there are several examples of the Auto-generated key but not for Sybase, like the examples
below can you provide one for sybase I have the following.... can anyone please help.....
 
******************my java ***************************
// Save the Provider that was created 
 private ProviderBean saveProvider(ProviderBean pb){
  SqlMapClient sqlMap = BSSqlMapConfig.getSqlMapInstance();
  try {
   sqlMap.startTransaction();
   System.out.println("we made it here * INSERT *line 159 pb = "); 
    Integer generatedProviderID = (Integer) sqlMap.insert("insertProvider", pb);
   pb.setId(generatedProviderID);
   System.out.println("we made it here line 164 " + pb.getId());
   sqlMap.commitTransaction();
  } 
  catch (SQLException e){
   e.printStackTrace();
  }
  finally {
   try {
    sqlMap.endTransaction();
   } catch (SQLException e1) {
    e1.printStackTrace();
   }
  }
  return null;
 }
 
************************ my XML *********************
  
  <insert id="insertProvider" parameterClass="gov.utah.dhs.dsamh.bs.beans.ProviderBean">

   INSERT INTO
    tbl_provider   (program,      short_program,   provider_name, 
        address,     address_2,    city,
        state,      zip_code,    zip_code_extension,  
        area_code,      phone,    phone_extension,
        url_address,      email,    contact_name,
       fax_area,     fax,    system_user_id, 
       create_date)
        
    values         (#program#,     #shortProgram#,  #providerName#,
        #address1#,       #address2#,   #city#,
        #state#,     #zipCode#,    #zipCodeExtension#,  
        #areaCode#,    #phone#,    #phoneExtension#,
        #urlAddress#,    #email#,   #contactName#,
       #faxArea#,     #fax#,    #systemUser#,
       #createDate#)
       
   <selectKey resultClass="Integer" keyProperty="id">
        SELECT LAST_INSERT_ID() AS id
    </selectKey>
  </insert>
 
 
 
 
 
 
 
<!*Oracle SEQUENCE Example -->
<insert id="insertProduct-ORACLE" parameterClass="com.domain.Product">
<selectKey resultClass="int" keyProperty="id" >
SELECT STOCKIDSEQUENCE.NEXTVAL AS ID FROM DUAL
</selectKey>
insert into PRODUCT (PRD_ID,PRD_DESCRIPTION)
values (#id#,#description#)
</insert>
<!* Microsoft SQL Server IDENTITY Column Example -->
<insert id="insertProduct-MS-SQL" parameterClass="com.domain.Product">
insert into PRODUCT (PRD_DESCRIPTION)
values (#description#)
<selectKey resultClass="int" keyProperty="id" >
SELECT @@IDENTITY AS ID
</selectKey>
</insert>
 
 
i
 
Dwight S. Galloway
(801) 538-4234
dsgallow@utah.gov 
Office of Technology
Department of Human Services
MAKE IT A GREAT DAY! 


Mime
View raw message