日期:2014-05-20  浏览次数:20856 次

Hibernate3.0生成表问题,在线等
我在配置完所有关于Hibernate的xml文件,向数据库生成表文件时出现了以下的错误,我实在是不知道哪里错了,不知道哪位大侠能帮小弟解决一下,小弟不胜感激。
错误:
21:37:42,656     INFO   HbmBinder:824   -   Mapping   subclass:   cn.oshell.user.User_Music   ->   UserSave
21:37:42,656     INFO   HbmBinder:824   -   Mapping   subclass:   cn.oshell.user.User_Album   ->   UserSave
21:37:42,656     INFO   Configuration:1419   -   Configured   SessionFactory:   null
21:37:42,671     INFO   Dialect:103   -   Using   dialect:   org.hibernate.dialect.MySQLDialect
Exception   in   thread   "main "   java.lang.NullPointerException
at   org.hibernate.mapping.ManyToOne.createPropertyRefConstraints(ManyToOne.java:47)
at   org.hibernate.cfg.HbmBinder$ManyToOneSecondPass.doSecondPass(HbmBinder.java:2673)
at   org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1012)
at   org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:647)
at   org.hibernate.tool.hbm2ddl.SchemaExport. <init> (SchemaExport.java:96)
at   org.hibernate.tool.hbm2ddl.SchemaExport. <init> (SchemaExport.java:64)
at   com.Hibernate.ExportDV.main(ExportDV.java:14)

com.Hibernate.ExportDV:
public   static   void   main(String[]   args)   {
//   TODO   Auto-generated   method   stub
Configuration   cfg=new   Configuration().configure();
SchemaExport   export=new   SchemaExport(cfg);
export.create(true,   true);
}

hibernate.cfg.xml:
<hibernate-configuration>
<session-factory>
<property   name= "hibernate.connection.driver_class "> com.mysql.jdbc.Driver </property>
<property   name= "hibernate.connection.url "> jdbc:mysql://localhost/New_oshell </property>
<property   name= "hibernate.connection.username "> root </property>
<property   name= "hibernate.connection.password "> 123456 </property>
<property   name= "hibernate.dialect "> org.hibernate.dialect.MySQLDialect </property>
<property   name= "hibernate.show_sql "> true </property>

<mapping   resource= "cn/oshell/admin/Admin.hbm.xml "/>

<mapping   resource= "cn/oshell/film/Film.hbm.xml "/>
<mapping   resource= "cn/oshell/film/FilmNum.hbm.xml "/>

<mapping   resource= "cn/oshell/music/Album.hbm.xml "/>
<mapping   resource= "cn/oshell/music/Music.hbm.xml "/>
<mapping   resource= "cn/oshell/music/Singger.hbm.xml "/>

<mapping   resource= "cn/oshell/user/User.hbm.xml "/>
<mapping   resource= "cn/oshell/user/UserSave.hbm.xml "/>

</session-factory>


------解决方案--------------------
你有一个Hbm的多对一有问题
------解决方案--------------------
应该是某个映射文件出了错!
------解决方案--------------------
可能是 你在编写时出现了 少写映射文件···