Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Hibernate and ResultSet?
PostPosted: Mon May 14, 2012 3:44 am 

Joined: Mon May 14, 2012 3:31 am
Posts: 2
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:

SessionFactory sessionFactory =  sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Query q = session.createQuery("SELECT COUNT(ID) FROM bla");

and the error message:

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


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.