I'm working on switching my JPA persistence provider from EclipseLink 2.3 to Hibernate 3.6.5.Final. The problem is with a native query. Note: this wasn't a problem with EclipseLink. I'm trying to obtain a scalar value, a String
from a table that I don't have an Entity declared for. Here is the code:
Query q = em.createNativeQuery("select description from foo where foo_id = ?");
q.setParameter(1, fooId);
String description = (String)q.getSingleResult();
With Hibernate I get a ClassCastException
because the object returned is actually a proxy object. I don't know what type it is, but I know it isn't an array (object.getClass().isArray()
is false) and I know it isn't a List (object instanceof List
is false
).
What am I missing?