Document that DataIntegrityViolationException can also be thrown on read-only queries #32631
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: documentation
A documentation task
Milestone
Affects: at least v4.0.0+
The javadoc for
DataIntegrityViolationException
specifies "Exception thrown when an attempt to insert or update data results in violation of an integrity constraint.". However,HibernateJpaDialect#convertHibernateAccessException
will convert anyorg.hibernate.exception.DataException
to aDataIntegrityViolationException
.org.hibernate.exception.DataException
indicates "that evaluation of the valid SQL statement against the given data resulted in some illegal operation, mismatched types or incorrect cardinality", which isn't necessarily limited to inserts or updates. For example,org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00
on a select query with a null character in a query param can end up throwingorg.hibernate.exception.DataException
.It's slightly confusing that the documention for
DataIntegrityViolationException
specifies that it's only thrown on an insert or update, but it can also be thrown on read-only queries.The text was updated successfully, but these errors were encountered: