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: An association from the table t_orders refers to an unmapped class: hibenate.model.Customer
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1252)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at hibernate.hibernateSessionFactory.<clinit>(hibernateSessionFactory.java:26)
at test.main(test.java:13)
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource hibernate/orm/Customer.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 hibernate.hibernateSessionFactory.rebuildSessionFactory(hibernateSessionFactory.java:62)
at hibernate.hibernateSessionFactory.getSession(hibernateSessionFactory.java:47)
at test.main(test.java:13)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping hibernate.model.Customer.orders
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2066)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2041)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
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.main(test.java:14)
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: An association from the table t_orders refers to an unmapped class: hibenate.model.Customer
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1252)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at hibernate.hibernateSessionFactory.<clinit>(hibernateSessionFactory.java:26)
at test.main(test.java:13)
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource hibernate/orm/Customer.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 hibernate.hibernateSessionFactory.rebuildSessionFactory(hibernateSessionFactory.java:62)
at hibernate.hibernateSessionFactory.getSession(hibernateSessionFactory.java:47)
at test.main(test.java:13)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping hibernate.model.Customer.orders
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2066)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2041)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
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.main(test.java:14)
解决方案 »
- java wav语音文件合成
- hibernate.cfg.xml编码
- webwork验证问题
- jsp页面中session.getAttribute("rightAll")找不到session文件
- 请教一个JFileChooser.showSaveDialog中设置默认文件名
- 如何在myeclipse中使用hibernate配置连接oracle数据库连结池
- 线程问题 ,急急急急急急
- 使用Jbuilder 2006和Weblogic, Oracle开发session bean的时候,有关datasource的jndi在xml配置文件中的信息能不能能通过Jbuilder自动声称
- eclipse + lomboz + jboss4.0 + Oracle9i 下开发cmp自动生成代码的问题
- 两个8两个3算出24 微软招聘出怪招
- SSH菜鸟找高手
- oracle的9i和10g指的是oracle数据库的不同版本吧
<session-factory name="hibernateSessionFactory">
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">19861126</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:8080/webdb?characterEncoding=UTF-8</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <mapping resource="hibernate/orm/Customer.hbm.xml"></mapping>
<mapping resource="hibernate/orm/Order.hbm.xml"></mapping>
</session-factory><hibernate-mapping>
<class name="hibernate.model.Customer" table="t_customers" catalog="webdb">
<id name="id" column="id" type="int">
<generator class="increment" />
</id>
<property name="name" column="name" type="string" />
<set name="orders" cascade="save-update,delete" inverse="true"
order-by="order_number asc" lazy="true">
<key column="customer_id" />
<one-to-many class="hibernate.model.Order" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="hibernate.model.Order" table="t_orders" catalog="webdb">
<id name="id" column="id" type="int">
<generator class="increment" />
</id>
<property name="number" column="order_number" type="string" />
<many-to-one name="customer" column="customer_id"
class="hibenate.model.Customer"
cascade="save-update" >
</many-to-one>
</class>
</hibernate-mapping>
都告诉你错误在哪里了.映射的类在哪里,存在不,用IDE检查下你的HBM.XML文件对不
而且hbm.xml文件validate都未出错
class="hibenate.model.Customer"
cascade="save-update" >
</many-to-one>
hibernate.model.Customer写错了
<session-factory name="hibernateSessionFactory">
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost/webdb?characterEncoding=UTF8
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.provider_class">
org.hibernate.cache.HashtableCacheProvider
</property>
<property name="show_sql">true</property>
<property name="connection.password">19861126</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <mapping resource="hibernate/orm/Customer.hbm.xml"></mapping>
<mapping resource="hibernate/orm/Order.hbm.xml"></mapping>
</session-factory>
出现了数据库拒绝被访问,不过被我也给解决了
hbm.xml文件有问题吧...
关联到实体类Customer时出错,检查下