记hibernate一次坑

在使用hibernate反转工程时有一个坑放在这里,避免你们跳进去。本人用的是myeclipse2017ci,在使用hibernate反转工程生成原始dao方法时碰到的bug。在方法public Account findById(Long id)中有一段代码及其坑爹java

log.debug("getting Account instance with id: " + id);
		try {
			Account instance = (Account) getSession().get("Account", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}

改成原始的session.get(***.class,id)session

public Account findById(Long id) {
		log.debug("getting Account instance with id: " + id);
		try {
			Account instance = (Account) getSession().get(Account.class, id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

否则常常报错Exception in thread "main" org.hibernate.UnknownEntityTypeException: Unable to locate persister: Account并不是是本身配置文件写错了,而是传入的参数不许确,致使本身查了几天bug。eclipse