Mybatis+Oracle添加1条数据并返回数据的主键问题

Controller类

@RequestMapping(value = "/upload/{lid}", method = RequestMethod.POST)
public void toUploap(@PathVariable String lid, TAppPicList pic)  {
    // pic是添加的数据, apppicid为数据主键,此时对象中主键为null
    picService.insertPic(pic);
    // 获取对象主键
    System.out.println("返回的主键值是"+pic.getApppicid()); 
}

Mapperx.xml


    
      SELECT  'P00'||SQ_APPPICID.nextval as apppicid from dual
    
    insert into T_APP_PICLIST
    
      
        APPPICID,
      
      
        APPID,
      
      
        ORDERNO,
      
    
    
      
        #{apppicid,jdbcType=VARCHAR},
      
      
        #{appid,jdbcType=VARCHAR},
      
      
        #{orderno,jdbcType=VARCHAR},
      
    
  

你可能感兴趣的:(Mybatis+Oracle添加1条数据并返回数据的主键问题)