java - update table operation on Postgres database through xml file -


i getting error while updating content in table using postgres database through mapping xml file & service class created in java.

table structure, service class method, mapping xml file & test code follows

table :

create table "itinerary" (   "itineraryid" serial not null,    "customerid" character varying(10) not null,    "propertycode" character varying(10) not null,    "resvid" integer,    "profileid" integer not null,    "summary" character varying(140),    "description" text,    "createdby" character varying(50),    "createdon" timestamp without time zone,    "updatedby" character varying(50),     "updatedon" timestamp without time zone,     constraint pk_itinerary primary key ("itineraryid")  ) 

mapping xml file: update operation

   <update id="updateselective" parameterclass="com.ginfo.data.itinerary.itinerarydata">     update "itinerary"     <dynamic prepend="set">         <isnotnull prepend="," property="customerid">             "customerid" = #customerid:varchar#         </isnotnull>         <isnotnull prepend="," property="propertycode">             "propertycode" = #propertycode:varchar#         </isnotnull>         <isnotnull prepend="," property="resvid">             "resvid" = #resvid:integer#         </isnotnull>         <isnotnull prepend="," property="profileid">             "profileid" = #profileid:integer#         </isnotnull>         <isnotnull prepend="," property="summary">             "summary" = #summary:varchar#         </isnotnull>         <isnotnull prepend="," property="description">             "description" = #description:varchar#         </isnotnull>         <isnotnull prepend="," property="updatedby">             "updatedby" = "#updatedby:varchar#         </isnotnull>         <isnotnull prepend="," property="updatedon">             "updatedon" = now()         </isnotnull>     </dynamic>      <include refid="itinerary.where_primarykey_clause" /> </update> 

service class :

 public itinerarydata save( itinerarydata itinerary ) throws exception    {       integer itineraryid = null;       if( itinerary != null )        {          try {             itineraryid = itinerary.getitineraryid();             if(itineraryid == null) {                 itineraryid = itinerarydao.insert(itinerary);                 itinerary.setitineraryid(itineraryid);             }             else{                 itinerarydao.updateselective(itinerary);             }        }        } 

test code:

        itinerarydata tinerary = new itinerarydata();         itinerary.setitineraryid(23);         itinerary.setcustomerid("0064152669");         itinerary.setpropertycode("bhs");         itinerary.setresvid(9748);         itinerary.setprofileid(4618);         itinerary.setsummary("schedule preparation");         itinerary.setdescription("schedule preparation description");         itinerary.setupdatedby(testuser);         itinerarydata itinerary2 = itineraryservice.save(itinerary2);         asserttrue("itinerary  saved", itinerary2!= null && itinerary2.getitineraryid() != null); 

when run test code getting following stack trace

caused by: com.ibatis.common.jdbc.exception.nestedsqlexception:    --- error occurred in resources/ibatis/basesqlmap.xml.   --- error occurred while executing update.   --- check    update "itinerary"   set         "customerid" = ?        ,     "propertycode" = ?        ,     "resvid" = ?        ,     "profileid" = ?        ,     "summary" = ?        ,     "description" = ?        ,     "updatedby" = "?                          it."itineraryid"=?           .   --- check sql statement (preparation failed).   --- cause: java.lang.arrayindexoutofboundsexception     @ com.ibatis.sqlmap.engine.mapping.statement.mappedstatement.executeupdate(mappedstatement.java:110)     @ com.ibatis.sqlmap.engine.impl.sqlmapexecutordelegate.update(sqlmapexecutordelegate.java:457)     @ com.ibatis.sqlmap.engine.impl.sqlmapsessionimpl.update(sqlmapsessionimpl.java:90)     @ org.springframework.orm.ibatis.sqlmapclienttemplate$9.doinsqlmapclient(sqlmapclienttemplate.java:380)     @ org.springframework.orm.ibatis.sqlmapclienttemplate$9.doinsqlmapclient(sqlmapclienttemplate.java:1)     @ org.springframework.orm.ibatis.sqlmapclienttemplate.execute(sqlmapclienttemplate.java:200)     ... 44 more 

how make work?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -