objectbox-java
objectbox-java copied to clipboard
UniqueViolationException: insert the id of the duplicate document in an attribute
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.
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