recently done Mybatis+oracle project to solve add a piece of data and return the primary key issue for the added data
Controller layer
@RequestMapping ("/addplan") publicthrows exception{
//plan is the added data, Planid is the data primary key, when the primary key in the object is null int n = Service.insertonlineaddplan (plan);
//Get Object primary key System.out.println ("Return primary key value is" +Plan.getplanid ()); return plan; }
In the Mapperx.xml
<insert id= "Insert" parametertype= "Com.online.pojo.OnlineAddplanWithBLOBs" > //gets the sequence value and assigns a value to the object's Planid field <selectkey keyproperty= "Planid" resulttype= "DECIMAL" order= "before" > Select Online_sequence.nextval from dual </selectkey> Insert into Online_addplan (PLANID, completetime, person, operation, USERNAME, Eventnode, workplan, Chengguo Miaoshu)
//gets the value of the Planid field in the above object values (#{planid,jdbctype =decimal}, # {Completetime,jdbctype=timestamp}, #{person,jdbctype=varchar}, #{operation, Jdbctype =varchar}, #{username,jdbctype=varchar}, #{eventnode,jdbctype=CLOB} , #{workplan,jdbctype =clob}, #{chengguomiaoshu,jdbctype=clob}) </ Insert>
Mybatis+oracle adding a piece of data and returning the primary key problem for the added data