Skip to content

Document that DataIntegrityViolationException can also be thrown on read-only queries #32631

@kirk-b-hansen

Description

@kirk-b-hansen

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 any org.hibernate.exception.DataException to a DataIntegrityViolationException. 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 throwing org.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.

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions