hibernate报错(一)

来源:互联网 发布:swift 项目源码 编辑:程序博客网 时间:2024/05/18 02:45
Exception in thread "main" org.hibernate.MappingException: could not instantiate id generator [entity-name=com.xss.domain.Employee]
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:224)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at com.xss.view.testMain.main(testMain.java:15)
Caused by: org.hibernate.MappingException: could not interpret id generator strategy: sequence 
at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:151)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:124)
... 4 more
<?xml version="1.0" encoding="UTF-8"?><!-- 该文件要清楚地表述出类和表的对应关系 --><!DOCTYPE hibernate-mapping PUBLIC"-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><!-- package :表示该类在哪一个包下 --><hibernate-mapping package="com.xss.domain"><!-- name:表示类名;table:表示该类和哪一个表映射 --><class name="Employee" table="employee"><!-- id 元素专门用于指定主键是如何生成,hibernate设计者认为,我们每一个表都应该拥有一个主键 --><id name="id" column="id"  type="java.lang.Integer"><!-- 指定主键生成策略 --><generator class="sequence "><param name="sequence">EMP_SEQ</param></generator></id><!-- 配置其他属性 --><property name="name" type="java.lang.String"><column name="name" not-null="false"/></property><property name="email" type="java.lang.String"><column name="email" not-null="false"/></property><property name="hiredate" type="java.util.Date"><column name="hiredate" not-null="false"/></property></class></hibernate-mapping>



错误是因为:

<id name="id" column="id"  type="java.lang.Integer"><!-- 指定主键生成策略 --><generator class="sequence "><param name="sequence">EMP_SEQ</param></generator></id>

class="sequence"多了一个空格

修改以后编译,运行正常!!


0 0