# GenericJDBCException handling

**URL:** <https://discourse.hibernate.org/t/genericjdbcexception-handling/920>\
**Category:** Hibernate ORM\
**Created:** [June 13, 2018, 7:39am UTC](https://discourse.hibernate.org/t/genericjdbcexception-handling/920 "2018-06-13T07:39:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![caristu](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@caristu](https://discourse.hibernate.org/u/caristu)\
**Post date:** [June 13, 2018, 7:39am UTC](https://discourse.hibernate.org/t/genericjdbcexception-handling/920/1 "2018-06-13T07:39:30Z")

</div>

Hello,

in Hibernate 5.3, if a GenericJDBCException occurs, for example when flushing same changes into the database the exception is wrapped inside a PersistenceException[1].

I’m working to upgrade Hibernate from version 3.6. In such version GenericJDBCException were being directly thrown. So I’ve been forced to do some changes in my code in some try-catch blocks because they were no longer catching the exception properly (now I need to catch PersistenceException instead of GenericJDBCException)

I can do this changes in my code and also in some of the test cases affected by this change, but I’m still a bit concerned of third party code that can extend my application which I can’t control. After upgrading hibernate, if that code is managing the exceptions by catching GenericJDBCException it will stop working as expected…

What is your recommendation in this case? Do you have any suggestion about how I can manage this?

Thank you in advance.

[1] [https://github.com/hibernate/hibernate-orm/blame/master/hibernate-core/src/main/java/org/hibernate/internal/ExceptionConverterImpl.java#L149](https://github.com/hibernate/hibernate-orm/blame/master/hibernate-core/src/main/java/org/hibernate/internal/ExceptionConverterImpl.java#L149)

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [June 13, 2018, 8:17pm UTC](https://discourse.hibernate.org/t/genericjdbcexception-handling/920/2 "2018-06-13T20:17:37Z")

</div>

Just write the Hibernate exception into your own `DataAceessException` and your clients will be isolated from the underlying exception thrown by Hibernate.
