Dao.countOf(PreparedQuery) not working?

459 views
Skip to first unread message

jc

unread,
Nov 9, 2011, 8:17:25 PM11/9/11
to ORMLite Users
I'm updating to the latest version for Android and converting my
custom countOf() method to use the new method provided by the Dao. At
first glance, this appears to be an issue but I'm not sure if maybe I
missed something.It appears that this may but it's not working and
I'm not sure if this is a bug or.

I added "setCountOf(true)" to my query builder and when I call
countOf() I get the following "Cannot call query on a SELECT_LONG
statement":

11-09 18:42:32.184: ERROR/AndroidRuntime(2583):
java.lang.IllegalArgumentException: Cannot call query on a SELECT_LONG
statement
11-09 18:42:32.184: ERROR/AndroidRuntime(2583): at
com.j256.ormlite.android.AndroidCompiledStatement.runQuery(AndroidCompiledStatement.java:
49)
11-09 18:42:32.184: ERROR/AndroidRuntime(2583): at
com.j256.ormlite.stmt.StatementExecutor.queryForCountStar(StatementExecutor.java:
131)
11-09 18:42:32.184: ERROR/AndroidRuntime(2583): at
com.j256.ormlite.dao.BaseDaoImpl.countOf(BaseDaoImpl.java:678)

If I remove the setCountOf call, it fails with the expected error that
"Prepared query is not of type SELECT_LONG, did you call
QueryBuilder.setCountOf(true)":

11-09 18:35:50.102: ERROR/AndroidRuntime(2534):
java.lang.IllegalArgumentException: Prepared query is not of type
SELECT_LONG, did you call QueryBuilder.setCountOf(true)?
11-09 18:35:50.102: ERROR/AndroidRuntime(2534): at
com.j256.ormlite.dao.BaseDaoImpl.countOf(BaseDaoImpl.java:673)
11-09 18:35:50.102: ERROR/AndroidRuntime(2534): at
com.wm.ocs.android.da.database.dao.DaoImpl.countOf(DaoImpl.java:63)

The stacktraces are from 4.29, but I also tried the 4.30-SNAPSHOT and
get the same errors.

jc

unread,
Nov 9, 2011, 8:26:00 PM11/9/11
to ORMLite Users
I retract the last statement of my previous post. I tried this again
with the 4.30-SNAPSHOT and it does work now. I looked at the 4.29
code and this appears to be an issue with the 4.29 Android code and
the updates for 4.30 fix it.

Gray Watson

unread,
Nov 9, 2011, 9:12:01 PM11/9/11
to ormlit...@googlegroups.com

Yeah, this was a problem with the query typing that Pedro Velasco reported. Here's the bug report:

http://sourceforge.net/tracker/?func=detail&aid=3434508&group_id=297653&atid=1255989

I think 4.30 is ready for prime time so I'm going to start the release run right now. Need to choose a good release background music track. Hrm....
gray

Reply all
Reply to author
Forward
0 new messages