---
title: "Hibernate唯一约束配置"
author: "kkllmey"
date: "2009-04-01T11:37:01Z"
tags: []
slug: "hibernate"
draft: false
lastmod: "2009-04-01T11:37:01Z"
id: 358885
url: "https://ibc.iteye.com/blog/358885"
---

单个字段唯一约束：
<property name="userName" type="java.lang.String" column="`userName`" not-null="true" **unique**="true" length="20"/>

多个字段唯一约束：

<property name="name" type="String" **unique-key**="XXX" /> 
<property name="name2" type="String" **unique-key**="XXX"/>