In my Android project, ORMLite is functioning as a cache. I’m downloading data from a web server and placing it in the database. I’m calling createOrUpdate on my objects, but duplicates are appearing in the database. The database entries are identical except for the primary key (which is simply an auto incremented integer). I think that since my second object doesn’t yet have a primary key, ORMLite considers the two as being different, even though every other field is identical.
Does anyone know if this is true?
You should not be calling
createOrUpdateunless your object already has an id field set. The wayORMLitedetermines whether or not it exists in the database is to do a query-by-id on it. The code does:I’ll expand the javadocs to explain this better. They are very weak there. Sorry. I’ve updated them to be: