当code 和name在数据库中不允许重复的时候加上unique="true"就行了。
<property name="code" type="string"unique="true">
</property>
<property name="name"type="string">
</property>
还有一种情况:
如果:数据库中有信息:code=“1” name=“2”,现在要插入code="1" name="3"
如果是上面的配置的话肯定会报出code不能重复,
此时就需要将code和name设置相同的:unique-key=" "这样在插入数据的时候就会判断除非插入的数据相同的code对应的name也相同的话才会报框
<property name="code"type="string">
</property>
<property name="name"type="string">
</property>
http://blog.sina.com.cn/s/blog_63a3fd8f0100rldd.html
http://blog.sina.com.cn/s/blog_63a3fd8f0100rldd.html