Code:
public long count() {
....
String countQuery = "SELECT COUNT(t.id) FROM " + shortClassName + " t ";
TypedQuery<Long> query = __entityManager.createQuery(countQuery, Long.class);
Long count = query.getSingleResult();
return(count);
}
The exception stack is below --
java.lang.IndexOutOfBoundsException: Index: 0
at java.util.Collections$EmptyList.get(Collections.java:4454)
at org.hibernate.ogm.query.impl.OgmQueryLoader.listOfArrays(OgmQueryLoader.java:105)
at org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:73)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497)
at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:127)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1300)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
The entity is as follows :
Code:
@Entity
@Table(name="XXXXX"
)
public class XXXBean implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
....
}
If I replace COUNT by MAX or AVG (with suitable modification of the generic type in the TypedQuery<X>), it works fine ! Is there anything obvious, I am missing here ?