log4j:ERROR Could not find value for key log4j.appender.file
log4j:ERROR Could not instantiate appender named "file".
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: An association from the table d_category_product refers to an unmapped class: com.Catepory
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1134)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
at util.HibernateUtil.<clinit>(HibernateUtil.java:35)
at dao.BasicDAO.getSession(BasicDAO.java:9)
at dao.CategoryDAO.findAll(CategoryDAO.java:13)
at test.TestCategory.main(TestCategory.java:14)
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: mapping/Category.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 util.HibernateUtil.rebuildSessionFactory(HibernateUtil.java:98)
at util.HibernateUtil.getSession(HibernateUtil.java:82)
at dao.BasicDAO.getSession(BasicDAO.java:9)
at dao.CategoryDAO.findAll(CategoryDAO.java:13)
at test.TestCategory.main(TestCategory.java:14)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.Category.subCats
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2030)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2005)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:368)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
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)
... 10 more
Exception in thread "main" java.lang.NullPointerException
at dao.CategoryDAO.findAll(CategoryDAO.java:13)
at test.TestCategory.main(TestCategory.java:14)Category.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 Persistence Tools
-->
<hibernate-mapping package="com">
<class catalog="dangdang" name="Category" table="d_category">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<!-- 当前类别包含的子类别 -->
<list name="subCats" >
<key column="parent_id"></key>
<list-index column="turn"></list-index>
<one-to-many class="Category"></one-to-many>
</list>
<!-- catepory到product的多对多映射-->
<!-- <set name="products" table="d_category_product">-->
<!-- <key column="cat_id"></key>-->
<!-- <many-to-many class="Product" column="product_id"></many-to-many>-->
<!-- </set>-->
<property generated="never" lazy="false" name="turn"
type="java.lang.Integer">
<column name="turn" not-null="true" />
</property>
<property generated="never" lazy="false" name="enName"
type="java.lang.String">
<column length="200" name="en_name" not-null="true" />
</property>
<property generated="never" lazy="false" name="name"
type="java.lang.String">
<column length="200" name="name" not-null="true" />
</property>
<property generated="never" lazy="false" name="description"
type="java.lang.String">
<column length="200" name="description" />
</property>
<property generated="never" lazy="false" name="parentId"
type="java.lang.Integer">
<column name="parent_id" />
</property>
</class>
</hibernate-mapping>
Category.java
package com;import java.util.List;
import java.util.Set;// default package/**
 * Category entity. @author MyEclipse Persistence Tools
 * 书本种类 分为3级  
 *  1.一个种类 就是   图书 
 *  2.就是  图书的  分类  譬如  :小说  军事 电脑 之类的 
 *  2.最后一级就是分类下的 具体书本了 
 */public class Category implements java.io.Serializable { // Fields private Integer id;
private Integer turn;
private String enName;
private String name;
private String description;
private Integer parentId;
private Set<Product> products;
private List<Category> subCats; // Constructors /** default constructor */
public Category() {
} /** minimal constructor */
public Category(Integer turn, String enName, String name) {
this.turn = turn;
this.enName = enName;
this.name = name;
} /** full constructor */
public Category(Integer turn, String enName, String name,
String description, Integer parentId) {
this.turn = turn;
this.enName = enName;
this.name = name;
this.description = description;
this.parentId = parentId;
} // Property accessors public Integer getId() {
return this.id;
} public void setId(Integer id) {
this.id = id;
} public Integer getTurn() {
return this.turn;
} public void setTurn(Integer turn) {
this.turn = turn;
} public String getEnName() {
return this.enName;
} public void setEnName(String enName) {
this.enName = enName;
} public String getName() {
return this.name;
} public void setName(String name) {
this.name = name;
} public String getDescription() {
return this.description;
} public void setDescription(String description) {
this.description = description;
} public Integer getParentId() {
return this.parentId;
} public void setParentId(Integer parentId) {
this.parentId = parentId;
} public void setProducts(Set<Product> products) {
this.products = products;
} public Set<Product> getProducts() {
return products;
} public void setSubCats(List<Category> subCats) {
this.subCats = subCats;
} public List<Category> getSubCats() {
return subCats;
}}