标签:http dal map sequence names type class utf-8 ring
在数据库设计的时候我们可以将表的ID定义为String
然后我们可以使用序列来得到唯一的ID
手写一个mapper:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="cn.allcheer.acl.omc.dal.dao.SequenceMapper"> <select id="getSequenceNextVal" parameterType="map" resultType="long"> select ${seqName}.nextval as ID from dual </select> </mapper>
给对象设置ID的时候:
obj.setId(sequenceMapper.getSequenceNextVal("sequence_role_ID"));
标签:http dal map sequence names type class utf-8 ring
原文地址:http://www.cnblogs.com/aigeileshei/p/6150641.html