objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

UniqueViolationException: insert the id of the duplicate document in an attribute

Open andrew-ld opened this issue 3 years ago • 1 comments

UniqueViolationException currently in the instances created by objectbox itself in the error message is the id that conflicts with the document we want to insert, I wonder if it is possible to add this id as an attribute of the UniqueViolationException class, it would be useful.

andrew-ld avatar Dec 22 '21 13:12 andrew-ld

Thanks for the suggestion! I guess the expectation in this case is that the code never does a conflicting insert, e.g. it does a query beforehand to find a possible duplicate. Which can be used to obtain the object ID of a potential duplicate.

Or if the old object should be replaced, use the replace conflict strategy. https://docs.objectbox.io/entity-annotations#unique-constraints

greenrobot-team avatar Jan 10 '22 07:01 greenrobot-team