Currently Hibernate supports return type *Map<String,String>* but it does not support *Map<String,Object>.* *Example:*
{code}class User { long id; String imageUrl; Address address;
//remaining mapping attributes . . . }
class Address { String name; }{code}
*My Criteria Query:*
{code}CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = builder.createTupleQuery(); Root<User> root = cq.from(User.class); cq.multiselect( root.get("imageUrl"), root.get("address")); cq.where(builder.equal(root.get("id"),3)); Tuple tuple = entityManager.createQuery(cq).getSingleResult(); tuple.get(0); // Error occurs for below code. (Stack over flow exception) tuple.get(1);{code}
While getting {{imageUrl}} there is no error but when it tries to fetch {{address}} \[Address type not string] attribute hibernate triggers stack over flow exception because it was trying to convert address to string.
|
|