[jboss-user] [JBoss Seam] - How to use EntityManager for SELECT COUNT(1)?

tonylmai do-not-reply at jboss.com
Wed Aug 15 19:36:20 EDT 2007


First I'd like to apologize for posting a persistence question on this board. I've tried other boards but no one's home. I am desperate :-(

I would like to perform a SELECT COUNT(1) FROM a table "TableA" but can't seem to get the SQL statement to work with EntityManager. The following code always return a 0 even I know the table contains hundreds of records.

int rowCnt= (Integer) em.createQuery("SELECT count(1) FROM TableA").getSingleResult();

Can anyone help?

I am using JBoss 4.2.1 with Seam 1.2.1. Thanks.
-tony

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074624#4074624

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074624



More information about the jboss-user mailing list