日期:2014-05-19  浏览次数:20842 次

hibernate实现一一关联报错什么情况
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% 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.createIdentifierGenerator(SimpleValue.java:152)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:192)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.util.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31)
at test.Test.main(Test.java:13)
Caused by: org.hibernate.MappingException: param named "property" is required for foreign id generation strategy
at org.hibernate.id.ForeignGenerator.configure(ForeignGenerator.java:82)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94)
... 5 more
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource org/model/Detail.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.util.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at org.util.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at test.Test.main(Test.java:13)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping org.model.Detail
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 8 more
Exception in thread "main" java.lang.NullPointerException
at test.Test.main(Test.java:15)


------解决方案--------------------
好像是说没有ID的主键增长策略

<generator class="sequence" />
------解决方案--------------------
主键生成策略问题,如果用的是oracle自增长序列,需要到oracle中去新建这个序列,此能使用。
------解决方案--------------------
映射文件错误,你配置的有问题,你用的SQL?SQL的直接配置indentity写了么?
------解决方案--------------------
LZ要一层一层检查。 
1。主键问题
  自增类型的话,用 <generator class="native"/>
2。param named "property" is required for foreign id generation strategy
  hibernate中id映射错误
3。Could not parse mapping document from resource org/model/Detail.hbm.xml
  hibernate mapping中resource 路径可能有问题或文件名,类名有写错的。
4。org.hiberna