hibernate3.0升级到4.2后Configuration.addClass无法加载

最近公司准备重新使用ssh,在之前有的项目上升级ssh版本,spring和struts都升级好了,现在在升级hibernate到最新版的时候遇到了问题,原本Configuration.addClass可以加载对应信息,然后用Configuration.getClassMapping获取加载的信息,但现在hibernate4.2后我试了很久都加载不了,请问是什么问题?下面是样例
import java.util.Date;

import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.PersistentClass;

public class testHibernater {
public static void main(String[] args){
TsCacheTablesInfo tsc=new TsCacheTablesInfo("ts_ccc", 10, new Date());
Configuration hibernateConf = new Configuration();
hibernateConf.addClass(tsc.getClass());
PersistentClass pc = hibernateConf.getClassMapping(tsc.getClass().getName());
System.out.println(pc);
}
}

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">




















package cn.com.jandar.oasis.evolution1.db.orm;

import java.util.Date;

/**

  • TsCacheTablesInfo entity.
  • @author MyEclipse Persistence Tools */

@SuppressWarnings("unchecked")
public class TsCacheTablesInfo implements java.io.Serializable {

// Fields

private Integer id;
private String tableName;
private Integer tableCount;
private Date lastChangeDt;
private Short enabled;

// Constructors

/** default constructor */
public TsCacheTablesInfo() {
}

/** minimal constructor */
public TsCacheTablesInfo(String tableName, Integer tableCount,
        Date lastChangeDt) {
    this.tableName = tableName;
    this.tableCount = tableCount;
    this.lastChangeDt = lastChangeDt;
}

/** full constructor */
public TsCacheTablesInfo(String tableName, Integer tableCount,
        Date lastChangeDt, Short enabled) {
    this.tableName = tableName;
    this.tableCount = tableCount;
    this.lastChangeDt = lastChangeDt;
    this.enabled = enabled;
}

// Property accessors

public Integer getId() {
    return this.id;
}

public void setId(Integer id) {
    this.id = id;
}

public String getTableName() {
    return this.tableName;
}

public void setTableName(String tableName) {
    this.tableName = tableName;
}

public Integer getTableCount() {
    return this.tableCount;
}

public void setTableCount(Integer tableCount) {
    this.tableCount = tableCount;
}

public Date getLastChangeDt() {
    return this.lastChangeDt;
}

public void setLastChangeDt(Date lastChangeDt) {
    this.lastChangeDt = lastChangeDt;
}

public Short getEnabled() {
    return this.enabled;
}

public void setEnabled(Short enabled) {
    this.enabled = enabled;
}

}

哈哈,自己解决了,hibernate4之后的版本Configuration类addClass后需要buildSessionFactory,不然不会生效

推送http://m.blog.csdn.net/blog/jdd0603/5366881常见的问题hibernate中的