Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No access to ConstraintViolationException.constraintName #1369

Closed
borellda opened this issue Aug 3, 2022 · 4 comments · Fixed by #1807
Closed

No access to ConstraintViolationException.constraintName #1369

borellda opened this issue Aug 3, 2022 · 4 comments · Fixed by #1807
Labels
enhancement New feature or request waiting We are waiting for another PR or issue to be solved before merging this one
Milestone

Comments

@borellda
Copy link

borellda commented Aug 3, 2022

Hello Hibernate team,

I'm migrating an existing app to Quarkus and I want also to use Hibernate reactive.
Quarkus platform version is: 2.11.1.Final
In the current dependency pulled in: org.hibernate.reactive:hibernate-reactive-core:1.1.7.Final, it seems there is no access to the "constraintName" property of ConstraintViolationException class.
Is this on purpose, then how can I check the reason of the violation.
Could you please have a look?

Regards,
Daniel

@DavideD DavideD added the enhancement New feature or request label Aug 3, 2022
@DavideD
Copy link
Member

DavideD commented Aug 3, 2022

You are right, we don't extract the code from the error message.
Right now you need to parse the error message if you want to extract the constraint name.

For future reference, at the moment the error message for Postgres is:

org.hibernate.HibernateException: io.vertx.pgclient.PgException: ERROR: duplicate key value violates unique constraint "uk_ddwji91nxj43borrm1ii72th8" (23505)

On top of this, we don't seem to throw the right exception when there is a constraint violation.
We should throw a ConstraintViolationException but we throw a generic HibernateException. It's possible to see this via MutinyExceptionsTest.

I've only given this a quick look though.
We should probably wait until the integreation with ORM 6 is done.

@borellda
Copy link
Author

borellda commented Aug 4, 2022

Thank you @DavideD for the very quick reply.
Didn't mention we are using Oracle, but I guess the message will be similar and I can deal with it.

Maybe worth to open another issue to track the Exception type issue, this seems to be more serious?

Best regards.

@gavinking
Copy link
Member

This was something I discusses with @tsegismont on the train one day recently.

Basically, the whole exception mapping stuff in Hibernate (IIRC) is currently unimplementable in HR because the SQL client doesn't expose the error codes we would need to implement that.

So this is actually bigger problem (really a missing feature).

I believe there is now issue open against the Vert.x client.

@gavinking gavinking added the waiting We are waiting for another PR or issue to be solved before merging this one label Aug 4, 2022
DavideD added a commit to DavideD/hibernate-reactive that referenced this issue Nov 29, 2023
DavideD added a commit to DavideD/hibernate-reactive that referenced this issue Nov 29, 2023
@DavideD
Copy link
Member

DavideD commented Nov 29, 2023

The SQL state or vendor error code are now accessible from the exception

@DavideD DavideD added this to the 2.2.1.Final milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request waiting We are waiting for another PR or issue to be solved before merging this one
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants