3
我在這裏有一個角落的情況。我想通過註釋配置MyBatis插入到MySql表中,並返回自動遞增鍵。我的方法是隻能用原語雖然不是POJO:MyBatis插入和返回鍵 - 註解/主要/ MySql
@Insert("INSERT into my_list (created_by_id, name) values (#{userId}, #{name})")
@Options(useGeneratedKeys=true)
long insert(@Param("userId") long userId, @Param("name") String name);
如何判斷的MyBatis的關鍵映射回該方法返回參數(而不是一個POJO成員變量)?
,我發現了異常:
org.mybatis.spring.MyBatisSystemException: nested exception is
org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting
result to parameter object.
Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available
parameters are [userId, name, param1, param2]
您是否曾經能夠在不使用POJO解決方案的情況下做到這一點? – Rob