eclipse+hibernate+mysql遇到的问题

yuanliniuniu 2008-08-27 03:50:00
%%%% Error Creating SessionFactory %%%%
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 com.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31)
at test.TestScore.setUp(TestScore.java:16)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.MappingException: could not interpret id generator strategy:
at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:108)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:91)
... 16 more
INFO org.hibernate.cfg.Configuration:1308 - configuring from resource: /hibernate.cfg.xml
INFO org.hibernate.cfg.Configuration:1285 - Configuration resource: /hibernate.cfg.xml
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: com/model/Admin.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at com.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at com.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at test.TestScore.setUp(TestScore.java:16)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.model.Admin
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 19 more

哪位高手可以指导一下,这是那里出了问题?谢谢了
...全文
61 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jojoy_828 2008-08-27
  • 打赏
  • 举报
回复
1、org.hibernate.MappingException: Could not read mappings from resource: com/model/Admin.hbm.xml
这个异常表示这个com/model/Admin.hbm.xml配置文件出错。
2、INFO org.hibernate.cfg.Configuration:1308 - configuring from resource: /hibernate.cfg.xml
INFO org.hibernate.cfg.Configuration:1285 - Configuration resource: /hibernate.cfg.xml
%%%% Error Creating SessionFactory %%%%
这个异常应该是你hibernate.cfg.xml 配置错误,导致连接不上数据库。
jojoy_828 2008-08-27
  • 打赏
  • 举报
回复
看这里就知道啦!org.hibernate.MappingException: could not instantiate id generator
这是你的某个pojo的.hbm.xml的配置出错了。
如:
<hibernate-mapping>
<class name="service.po.UserRole" table="T_User_Role">
<id name="id" type="integer">
<column name="id" />
<generator class="identity" />
</id>

<property name="userid" type="integer">
<column name="userid" not-null="true" />
</property>
<property name="roleid" type="integer">
<column name="roleid" not-null="true" />
</property>
</class>
</hibernate-mapping>
就是红色标识这一段出错了。

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧