1.配置文件是这样的
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="connection.url">jdbc:hsqldb:mem:test//localhost</property>
<!--<property name="connection.url">jdbc:hsqldb:file:/D:/Java/hsqldb-2.1.0/data/test</property> -->
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.isolation">2</property>
<property name="format_sql">true</property>
<!-- 自动创建表模式 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="show_sql">false</property>
<property name="myeclipse.connection.profile"></property>
<mapping class="com.simple.persistence.entity.Userinfo"/>
2.启动报错为:
[main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - Unsuccessful: create table userinfo
(id varchar(32) not null, address varchar(64), birthday date,
password varchar(16) not null, username varchar(16) not null, primary key (id), unique (id))
[main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - a UNIQUE constraint already exists on the set of columns in statement [
create table userinfo (
id varchar(32) not null,
address varchar(64),
birthday date,
password varchar(16) not null,
username varchar(16) not null,
primary key (id),
unique (id)
)]
不晓得什么哪里错误
------解决方案--------------------------------------------------------
primary key (id),
unique (id)
你重复定义了unique约束。
去掉后边的,unique(id)就可以了