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 9276125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:45:46+00:00 2026-06-18T16:45:46+00:00

I’m targeting Android 2.2 and newer. This error was generated on a device running

  • 0

I’m targeting Android 2.2 and newer. This error was generated on a device running 4.x. I am using ORMLite 4.38 libraries.

I need to guarantee every record instance is unique for any number of devices. I was happy to see that ORMLite supports UUIDs as IDs. I’ve created a UUID – id abstract base class for my database record definitions. allowGeneratedIdInsert is the perfect solution. But this feature seems to cause an ‘IllegalStateException: could not create data element in dao’. I tested by removing this annotation, and no issue. Put it back in…same issue. Put the base class stuff in one record definition…same issue.

LogCat also reports:

Caused by: java.sql.SQLException: Unable to run insert stmt on object – objectid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx

public abstract class UUIDDaoEnabled<T> extends BaseDaoEnabled<T, UUID> {

    //allowGeneratedIdInsert allows us to set UUID when this device db didn't create it
    @DatabaseField(generatedId = true, allowGeneratedIdInsert=true)
    private UUID id;
    ...
    public void setUUIDFromSerializedSource(SerializedModelBinaryInputStream stream, Dao<T, UUID> dao) throws SQLException { //only place we can set UUIDs
        if(id == null)
            dao.refresh((T)this); 

        if(id != null)
            throw new SQLException("Trying to set UUID on existing object");

        id = stream.getCurrentUUID();
    }
    }

I’ll specialize like so:

@DatabaseTable()
public class Type extends UUIDDaoEnabled<Type> { ... }

I can’t explain this from the documentation for allowGeneratedIdInsert and generatedId. In fact the documentation for alloeGeneratedIdInsert says it overrides the default behavior of generatedId. It also says

This only works if the database supports this behavior

Yet, I have read in other posts that ORMLite 4.25 (?) and newer supports this behavior on Android devices. So, either that’s not entirely true. Or I’m doing something stupid…anyone???

UPDATE: after thinking about it for a minute, I realized that neither allowGeneratedIdInsert support, nor inheritance can be the root cause, because I instantiate other objects based on the same abstract class. What I can’t figure out is why one particular class is causing the issue. The only unique thing about the offending record type (compared to other types that create) is it is a many in a one to many, and it contains several to manies. Could these properties, combined with allowGenereatedIdInsert, be the root issue? Rather, I should ask, has anyone seen this issue in this circumstance?

UPDATE: nevermind the question. I can use updateId(...) instead of allowGeneratedIdInsert.

  • 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-18T16:45:47+00:00Added an answer on June 18, 2026 at 4:45 pm

    So I’m not sure about this but it looks to me that you are trying to insert an element twice into a table with the same UUID id. The exception is saying there is a constraints failure:

    IllegalStateException: Could not create data element in dao
        at BaseForeignCollection.add(BaseForeignCollection.java:57)
    ...
    Caused by: SQLiteConstraintException: error code 19: constraint failed
    

    If you call foreignCollection.add(...); it does the same thing as dao.create(...); — and you can’t do both of these with the same object. If you have an existing object that has already been created by the DAO and you want to associate it with another object, you should do something like:

       // associate this object with another
       existingObject.setForeignField(...);
       // now update it in the db
       existingObjectDao.update(existingObject);
    

    You can’t add it to the foreignField’s foreign collection.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

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.