怎么解决,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
检查下你的hibernate的配置文件怎么配置的。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 配置 hibernate 的基本信息 -->
<!-- hibernate 所使用的数据库方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<!-- 执行操作时是否在控制台打印 SQL -->
<property name="hibernate.show_sql">true</property>
<!-- 是否对 SQL 进行格式化 -->
<property name="hibernate.format_sql">true</property>
<!-- 指定自动生成数据表的策略 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.autocommit">true</property>
</session-factory>
</hibernate-configuration>
数据库中的主键和外键以及unique的基本用法如下:
1 主键在表中是唯一性的,并且主键所在的字段不能为空,且一个表中,只有一个主键或一个联合主键。
2 当一个表引用外键时,被引用的表中字段必须是主键或unique
所以这是hibernate遵循的数据库的基本语法,并没有错误啊。
检查你数据库表