org.hibernate.MappingException Unknown entity: AFullyQualifiedClassName

I was struggling with this error after having generated the DAO classes using MyEclipse IDE.
My hibernate configuration file was alright, the libs were in place (hibernate3.jar ,hibernate-annotations.jar) and so was the desired mapping path present...
mapping resource="com/bmb/model/BlogFeed.hbm.xml"

I was importing the proper classes for the annotations

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

But the compiler continued to shout :

15:13:48,959 DEBUG BlogFeedDAO:62 - getting BlogFeed instance with id: 1
Entity retrieval failed.15:13:48,961 ERROR BlogFeedDAO:68 - get failed
org.hibernate.MappingException: Unknown entity: BlogFeed.class

Finally after hours, I realized the mistake and changed the code from orange to green...


public BlogFeed findById( java.lang.Integer id) {
log.debug("getting BlogFeed instance with id: " + id);
try {

//error BlogFeed instance = (BlogFeed) getSession().get("BlogFeed", id);

BlogFeed instance = (BlogFeed) getSession().get(BlogFeed.class, id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}

Having this -
Object org.hibernate.Session.get(Class arg0, Serializable arg1) throws HibernateException, forces the compiler to fetch the class (you can also specify the fully qualified class name).

Popular posts from this blog

Thinking about Forms and Usability...

IFE - A Charity to promote the message of PEACE.

Creating Combobox within a DataGrid column in Flex