I need to select a specific row from my Oracle DB into my entity class and I use this code:
MyEntity ent= (MyEntity) entityManager.createQuery("from MyEntity where col1 \= (select max(col1) from MyEntity where ent_id\=:ent)\") .setParameter(\"ent\", \"xxx\") .getSingleResult();
The problem is that I get the following exception when I try to execute this:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode \-[AGGREGATE] AggregateNode: 'max' \-[IDENT]
Could anyoneone please tell me what is wrong with this and how could I fix it.
Actually I found the problem. It's not the aggregate function, but the names of the entity properties. Got them wrong.