Hello guys,
i am using hibernate 3.5.6 and there i have an object "ResultSet". This is very handy for me cause of fetching only one value from an table. There i don't need the mapping to the table.
Now i need to use hibernate 4.1.3 instead of 3.5.6 and there is no object "ResultSet". The examples show only fetching data with mapping to an specific class. But if i need something like that: "SELECT COUNT(ID) FROM bla WHERE ID > 4" i don't wont to use the mapping because it is only a single value and i want to get this value. How could i solve this? Above is my example code:
Code:
SessionFactory sessionFactory = sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Query q = session.createQuery("SELECT COUNT(ID) FROM bla");
and the error message:
Code:
org.hibernate.hql.internal.ast.QuerySyntaxException: HTS.RIN_ALL_ASSAY is not mapped [SELECT COUNT(ID) FROM HTS.RIN_ALL_ASSAY]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3270)
With best
bladepit