Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9172005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:14:32+00:00 2026-06-17T16:14:32+00:00

I’m using Ormlite with CursorLoader , using the ormlite-extras library (I use the package

  • 0

I’m using Ormlite with CursorLoader, using the ormlite-extras library (I use the package support.extras as I intend to target android 2.2 and up).

I have the following exception :

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: column '_id' does not exist
    at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:314)
    at android.support.v4.widget.CursorAdapter.swapCursor(CursorAdapter.java:344)
    at rainstudios.meleo.ui.eventlv.EventLvFragment.onLoadFinished(EventLvFragment.java:274)
    at rainstudios.meleo.ui.eventlv.EventLvFragment.onLoadFinished(EventLvFragment.java:1)
    at android.support.v4.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:427)
    at android.support.v4.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:395)
    at android.support.v4.content.Loader.deliverResult(Loader.java:103)
    at rainstudios.meleo.data.RainstudiosOrmliteCursorLoader.deliverResult(RainstudiosOrmliteCursorLoader.java:68)
    at rainstudios.meleo.data.RainstudiosOrmliteCursorLoader.deliverResult(RainstudiosOrmliteCursorLoader.java:1)
    at android.support.v4.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:221)
    at android.support.v4.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:61)
    at android.support.v4.content.ModernAsyncTask.finish(ModernAsyncTask.java:461)
    at android.support.v4.content.ModernAsyncTask.access$500(ModernAsyncTask.java:47)
    at android.support.v4.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:474)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3835)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
    at dalvik.system.NativeStart.main(Native Method)

I did some digging and noticed that indeed '_id' is not present in the results returned by the code in the CursorLoader.

For more information, please see the code above :

/* Runs on a worker thread */
@Override
public Cursor loadInBackground() {
    Cursor cursor = null;
    try {
        CloseableIterator<T> iterator = mDao.iterator(mQuery);

        // get the raw results which can be cast under Android
        AndroidDatabaseResults results = (AndroidDatabaseResults) iterator
                .getRawResults();
        cursor = results.getRawCursor();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    if (cursor != null) {
        // Ensure the cursor window is filled
        cursor.getCount();
        registerContentObserver(cursor, mObserver);
    }
    return cursor;
}

Using the debugger, it appears the following :

results.columnNameMap = [id, code, name, popular, rating, voteCount, shortDescription, description, hoursDescription, url, modificationDate, syncDate, artist_id, district_id, pictures, frontPicture, userRating, venue_id, userComment, userFavorite, situation_id, caFrontPictureId, caResources]

results.columnNames = {syncDate=11, userRating=16, district_id=13, pictures=14, userFavorite=19, artist_id=12, code=1, situation_id=20, frontPicture=15, voteCount=5, url=9, caResources=22, id=0, hoursDescription=8, userComment=18, shortDescription=6, description=7, popular=3, name=2, venue_id=17, rating=4, caFrontPictureId=21, modificationDate=10}

The creation of the prepared query is pretty standard :

public PreparedQuery<EventDb> findAllEventsQuery() {
    try {

        QueryBuilder<EventDb, Integer> eventQb = getEventDao()
                .queryBuilder();
        return eventQb.prepare();

    } catch (Throwable e) {
        Out.handleSilentError("Cannot retrieve all events", e);
    }
    return null;
}

I did the test executing the query and getting the results as a List : everything works alright.

For now, I’m puzzled.

Besides, I have another for the ormlite experts.

  • Am I supposed to close the iterator by calling iterator.closeQuietly() ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:14:33+00:00Added an answer on June 17, 2026 at 4:14 pm

    As pointed by @patheticpat, the solution is available on stackoverflow : ORMLite with CursorAdapter in Android

    Your id fields need to be mapped to a column named _id to use Cursor with Ormlite 4.42.

    Like this :

    @DatabaseTable(tableName = "event")
    public class EventDb extends BaseDaoEnabled<EventDb, Integer> {
    
        @DatabaseField(generatedId = true, columnName = "_id")
        int id;
    

    Note : And you can’t call iterator.closeQuietly() because it crashes.
    I hope that there is no memory leaked because if that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.