Hi,
I am trying to get hibernate-generic-dao to work using the generic DAO examples at
http://code.google.com/p/hibernate-generic-dao/wiki/GenericDAOExamples. I placed the 1.2 version of dao.jar and search.jar in my project. I am using Hibernate 4.2 and I am not using Spring.
I created a WebsiteDAO.java file, like so:
===================================
import java.util.List;
import com.googlecode.genericdao.dao.jpa.GenericDAO;
import com.pasionat.models.Website;
public interface WebsiteDAO extends GenericDAO<Website, Long> {
public List<Website> findByWebsiteType(String websiteType);
}
===================================
I created a WebsiteDAOMySQL.java file, like so:
============
import com.googlecode.genericdao.dao.jpa.GenericDAOImpl;
import com.googlecode.genericdao.search.Search;
import com.pasionat.models.Website;
public class WebsiteDAOMySQL extends GenericDAOImpl<Website, Long> implements WebsiteDAO {
public List<Website> findByWebsiteType(String websiteType)
{
return search(new Search().addFilterEqual("websiteType", websiteType));
}
}
======
Now when I call:
List<Website> websites = null;
websites = websiteDao.findAll();
I get:
Exception in thread "main" java.lang.NullPointerException
at com.googlecode.genericdao.dao.jpa.JPABaseDAO.getMetadataUtil(JPABaseDAO.java:82)
at com.googlecode.genericdao.dao.jpa.JPABaseDAO._all(JPABaseDAO.java:206)
at com.googlecode.genericdao.dao.jpa.GenericDAOImpl.findAll(GenericDAOImpl.java:61)
at com.pasionat.fetch.Main.main(Main.java:136)
And when I call:
List<Website> websites = null;
websites = websiteDao.findByWebsiteType("feed");
I get:
Exception in thread "main" java.lang.NullPointerException
at com.googlecode.genericdao.dao.jpa.JPABaseDAO._search(JPABaseDAO.java:322)
at com.googlecode.genericdao.dao.jpa.GenericDAOImpl.search(GenericDAOImpl.java:123)
at com.pasionat.dao.WebsiteDAOMySQL.findByWebsiteType(WebsiteDAOMySQL.java:145)
at com.pasionat.fetch.Main.main(Main.java:136)
I probably forgot something. But I can not figure out what. Could you please give me some pointers? Thanks.
Kind regards,
Nick