Hi ..
Using OpenJPA I have code running that implement a FastLaneReader pattern using createNativeQuery and a simple databean to be used in the UI layer. The case could be : I need to query a customer table in a separate schema (not managed by my application) and just display a list for selection.
I am unable to make this work using Hibernate (tried several versions inkl. latest )
Code:
...
String sql = "select custno at1, fullname at2, address at3 from customer";
EntityManager entityManager = factory.createEntityManager();
List<TestBean> items = new ArrayList<TestBean>();
try {
Query q = entityManager.createNativeQuery(sql, TestBean.class);
items = q.getResultList();
} catch (Exception e) {
e.printStackTrace();
}
...
The code above works fine in OpenJPA, but Hibernate reports
"Unknown entity: org.domain.test.dao.TestBean"
Is this working as designed, should'nt I be able to map to a simple non-managed bean? If not which is the best way to implement this scenario using hibernate entitymanager ?
Thanks
Anders Monrad