Hibernate中主建生成器问题请教!
Exception in thread "main "
org.hibernate.MappingException: could not instantiate id generator
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:97)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
at org.hibernate.impl.SessionFactoryImpl. <init> (SessionFactoryImpl.java:182)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at shop.lbh.fuzhu.HibernateSessionFactory.getSession(HibernateSessionFactory.java:17)
at shop.lbh.fuzhu.DbOperate.getSorts(DbOperate.java:141)
at shop.lbh.fuzhu.getSort.main(getSort.java:11)
Caused by: org.hibernate.
MappingException: Dialect does not support sequences
at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:531)
at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:65)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:93)
... 6 more
程序运行老是出现上面的异常错误:(
Sort.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 ">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name= "shop.lbh.vo.Sort " table= "sort " schema= "dbo " catalog= "shoppingOnlineDatabase ">
<id name= "id " type= "java.lang.Integer ">
<column name= "id " />
<generator class= "identity "/>
</id>
<property name= "name " type= "java.lang.String ">
<column name= "name " length= "40 " not-null= "true " />
</property>
</class>
</hibernate-mapping>
请求大家的帮忙,谢谢!
------解决方案--------------------不是这个XML文件,是你的那个hibernate.cfg.xml(默认应该是这个)有问题。
Caused by: org.hibernate.MappingException: Dialect does not support sequences
你那个文件里dialect设置的估计是oracle,但你用的却不是oracle数据库
------解决方案-------------------- at shop.lbh.fuzhu.HibernateSessionFactory.getSession(HibernateSessionFactory.java:17)