Seeing this Exception:
This is my POST Request.
I tried with different key value pairs. Still the same error.
My Entity Class.
Error
The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL200516190100880' defined on 'DATA_STORE'.
Anything I could be missing?
Related
I have just changed the primary key of an entity from long to uuid.
Now, when I try to change an object, javers fails with an Exception.
java.lang.IllegalArgumentException: Invalid UUID string: 7
at java.base/java.util.UUID.fromString(UUID.java:215)
at org.javers.core.json.typeadapter.util.UUIDTypeAdapter.deserialize(UUIDTypeAdapter.java:19)
at org.javers.core.json.typeadapter.util.UUIDTypeAdapter.deserialize(UUIDTypeAdapter.java:10)
at org.javers.core.json.BasicStringTypeAdapter.fromJson(BasicStringTypeAdapter.java:45)
at ........
at org.javers.spring.jpa.JaversTransactionalJpaDecorator.commit(JaversTransactionalJpaDecorator.java:50)
Javers seems to try to deserialize the old long-id as a UUID, which fails.
I could not find any recommended way of handling this situation.
I'm using Laravel's queue to retrieve data from API, when I'm being notified about changes through Webhooks. Webhook returns only id of the changed object, so I need to make a request to API to get the rest.
I dispatch the job to get the object by id, it runs in background (redis driver, supervisor). In queue I use:
Model::firstOrNew(['remote_id' => $id]);
but on ->save() I receive:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'tag-12' for key 'categories_type_remote_id_unique' (SQL: insert into categories...
If I debug this code using sync driver I can't reproduce this error, it only appears in background jobs. Like the job can't get the most recent data from DB and uses the new part of firstOrNew instead of first
the problem is for mysql .
you are entering duplicate entry 'tag-12'
find which keys you defined as unique . then change your firstOrNew method
I have created an entity class for my mvc application. But, my table doesn't have a primary key and the VS throws back an error:
"The table/view does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view."
Is there a way to still use the model even if it has no primary key??
or Do I have to add a pk? or should I just use execute command?
Any suggestion/comment is highly appreciated. Thanks in advance. :)
I have a web MVC project generated by Spring roo. I reverse engineered a MSSQL DB and have the need to create my own primary keys but am unable to insert using the inputs Roo generated (anticipates an auto increment or self-generated ID). Any ideas? I recieve the below message from the console when I attempt this.
ERROR org.hibernate.util.JDBCExceptionReporter - Field 'id' doesn't have a default value
It appears that the DBRE code generation for #ManyToOne/#JoinColumn is a bit incorrect. The code generator incorrectly sets such a field with "insertable = false" which then omits this particular foreign key column reference during an insert into the referencing table. Change it to "insertable = true" as well as the "updateable" if you require and you should be good.
I have written my DAO layer and service layer for my database using Spring.
In some of the tables we have unique constraints for some columns. If we try to insert the duplicate values for those columns, how do we catch those exceptions specifically based on the column name? Basically I need to know which column caused the query failure.
DAO operations which violate a unique key will throw a DataIntegrityViolationException. However, you won't easily be able to extract the specific column name from this, it's just not that detailed.
If you need this information, you should consider querying the database before you run the insert/update, checking that the constraint won't be violated. If that check fails, then you have your information.