Closed almozavr closed 13 years ago
Thanks for noticing that. We will investigate soon.
I also get another error after dozens of cursor related, but I'm not sure if they are linked somehow:
09-15 12:53:21.619: ERROR/AndroidRuntime(1715): java.util.MissingFormatArgumentException: Format specifier ''' 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.util.Formatter.getArgument(Formatter.java:1115) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.util.Formatter.doFormat(Formatter.java:1077) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.util.Formatter.format(Formatter.java:994) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.lang.String.format(String.java:2254) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.lang.String.format(String.java:2219) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at org.orman.util.logging.Log.trace(Log.java:48) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at org.orman.dbms.sqliteandroid.QueryExecutionContainerImpl.executeOnly(QueryExecutionContainerImpl.java:36) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at org.orman.mapper.Model.insert(Model.java:86) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at com.sample.project.ui.LauncherActivity$LoadMessagesTask.onPostExecute(LauncherActivity.java:111) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at com.sample.project.ui.LauncherActivity$LoadMessagesTask.onPostExecute(LauncherActivity.java:1) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.os.AsyncTask.finish(AsyncTask.java:417) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.os.AsyncTask.access$300(AsyncTask.java:127) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.os.Handler.dispatchMessage(Handler.java:99) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.os.Looper.loop(Looper.java:123) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.lang.reflect.Method.invokeNative(Native Method) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at java.lang.reflect.Method.invoke(Method.java:521) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-15 12:53:21.619: ERROR/AndroidRuntime(1715): at dalvik.system.NativeStart.main(Native Method)
Full output for cursor error (sorry for not writing it all from the beginning):
09-15 13:00:00.919: ERROR/Cursor(3580): Finalizing a Cursor that has not been deactivated or closed. database = /data/data/com.sample.project/databases/app.db, table = null, query = SELECT * FROM stream WHERE stream.id LIKE '9767';
09-15 13:00:00.919: ERROR/Cursor(3580): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
09-15 13:00:00.919: ERROR/Cursor(3580): at android.database.sqlite.SQLiteCursor.
The exception
java.util.MissingFormatArgumentException: Format specifier '''
caused by it is trying to log executed SQL to the stream but your query has %
(probably in LIKE
clause) and that character behaves like a format parameter (like %s
, %d
) and causes error. I will fix it later. If you want to continue development, you can comment out org.orman.dbms.sqliteandroid.QueryExecutionContainer.java
line 36, 47, 90 (that has Log.trace(..)
) and rake
again.
Sorry about this bug. I will be investigating cursor issue separately.
OK, thanks for quick response.
Regards, Aleksey Malevaniy
On 15 September 2011 13:49, ahmet alp balkan reply@reply.github.com wrote:
The exception
java.util.MissingFormatArgumentException: Format specifier '''
caused by it is trying to log executed SQL to the stream but your query has
%
(probably inLIKE
clause) I will fix it later. If you want to continue development, you can comment outorg.orman.dbms.sqliteandroid.QueryExecutionContainer.java
line 36, 47, 90 (that hasLog.trace(..)
) andrake
again.Sorry about this bug. I will be investigating cursor issue separately.
Reply to this email directly or view it on GitHub: https://github.com/ahmetalpbalkan/orman/issues/29#issuecomment-2103172
OK, telling long story short the problem appears when: I have a entity class, e.g. Message that has a field ref. entity class User. So when I simply:
for (int i = 0; i < 50; i++) {
Message message = new Message("Sample Text", new User("Sample User"));
User user = new User("Another User);
user.insert();
}
After some iterations it starts throwing:
_Finalizing a Cursor that has not been deactivated or closed. database = data/data/com.sample.project/databases/app.db, table = null, query = SELECT last_insert_rowid()_
Thanks that's a helpful example. Probably it is caused because we don't close a cursor that we use many times and android is trying to .finalize()
it. We will be tracing this.
Hope it helps! The sad thing, that I was trying to use ORMan on production development but it seems I have to link objects with pure sqlite by hands now and wait while orman would be ready for it. Still think it's the best orm for android, you guys rock!
Regards, Aleksey Malevaniy
On 15 September 2011 14:28, ahmet alp balkan reply@reply.github.com wrote:
Thanks that's a helpful example. Probably it is caused because we don't close a cursor that we use many times and android is trying to
.finalize()
it. We will be tracing this.Reply to this email directly or view it on GitHub: https://github.com/ahmetalpbalkan/orman/issues/29#issuecomment-2103392
FIXED by adding cur.close where it supposed to be. What should I do next? Here is my code: http://pastebin.com/JgKgd8zA
Thanks for that. If you hit java.util.MissingFormatArgumentException
, I told you about it here. Do you hit something else?
Always nice to help!
java.util.MissingFormatArgumentException
— I commented lines you told me, thanks!
Now everything seems to work.
MissingFormatArgumentException
issue moved to #32, you can track about it there. I will be fixing soon. Meanwhile cursor issue will be fixed with your solution. Thanks @almozavr.
@almozavr please checkout the code from master
and build with rake
. If it solves your cursor issue you can now close the issue. Thanks for cooperation.
Great work, thanks.
Every request to db gives me following errors:
Am I doing something wrong or something wrong with framework? Must admit, that transactions work anyway, but I get all this errors and app crashes.