论坛首页 Java企业应用论坛

org.hibernate.MappingException

浏览 2489 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-09-24  
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: could not instantiate id generator
        at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:98)
++++++++++++++++++=
        at org.hibernate.mapping.SimpleValue.createIde
ntifierGenerator(SimpleValue.java:152)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:192)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
        at org.acm.maps.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:24)
        at org.acm.daoImpl.ClassesDaoImpl.getClasses(ClassesDaoImpl.java:24)
        at org.acm.struts.action.Test1.main(Test1.java:24)
Caused by: org.hibernate.MappingException: Dialect does not support sequences
        at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:596)
        at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:65)
        at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94)
        ... 6 more


xxx.hbm.xml代码如下:
<?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">
<hibernate-mapping>
  <class name="org.acm.domain.Classes" table="classes">
    <id column="id" name="id" type="integer">
      <generator class="sequence">
        <param name="sequence">classs_id_seq</param>
      </generator>
    </id>
    <property column="grade" name="grade" type="string" unique="true"/>
    <property column="class" name="cla" type="string" unique="true" />
  </class>
</hibernate-mapping>


ubuntu8.04下,PostgreSql8.3 + hibernate3出现这个异常

解决办法:

把xxx.hbm.xml文件里的<generator class="sequence">改成<generator class="native">,问题解决.成功从数据库里读取数据.


让Hibernate自己去找采用的主键生成方式.


虽然问题已解决,但是对这个问题的理解还是很模糊,请各位指教.


ps:问题解决了,都不好意思说,我的数据库方言配置出错了,我晕
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics