DemoMapper.java
//注意方法的返回值必须是void;
void add(Demo demo);
==============================================
demoMapper.xml:
<insert id="add" parameterType="com.demo.pojo.Demo">
<selectKey keyProperty="demoId" resultType="java.lang.String" order="BEFORE">
select replace(uuid(),'-','')
</slectKey>
select replace(uuid(),'-','')
</slectKey>
INSERT INTO
db_demo(
demo_id
,name
,age
)
VALUES
(
#{demoId}
,#{name}
,#{age}
)
</insert>
==============================================
DemoServiceImpl.java :
@Autowired
private demoMapper demoMapper;
public void add(Demo demo){
demoMapper.add(demo);
System.out.println(demo.getDemoId);
}