[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-2932) No ConstraintName when using PostgreSQL (BatchUpdateException instead of PSQLException)
Diego Pires Plentz (JIRA)
noreply at atlassian.com
Thu Nov 15 22:46:29 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2932?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Diego Pires Plentz resolved HHH-2932.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
> No ConstraintName when using PostgreSQL (BatchUpdateException instead of PSQLException)
> ----------------------------------------------------------------------------------------
>
> Key: HHH-2932
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2932
> Project: Hibernate3
> Issue Type: Sub-task
> Affects Versions: 3.2.2
> Environment: Postgres 8.2
> Reporter: Florian Rock
> Assignee: Diego Pires Plentz
> Priority: Minor
>
> > When using dialect org.hibernate.dialect.PostgreSQLDialect and a ConstraintViolationException is thrown, getConstraintName() does not get the right constraint name.
> > It seems that there is something wrong with the ConstraintNameExtractor.
> I still run into this problem.
> lets take a look into the PostgresDialect:
> ------ BOF ------
> private static ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
> public String extractConstraintName(SQLException sqle) {
> try {
> int sqlState = Integer.valueOf( JDBCExceptionHelper.extractSqlState(sqle)).intValue();
> switch (sqlState) {
> // CHECK VIOLATION
> case 23514: return extractUsingTemplate("violates check constraint \"","\"", sqle.getMessage());
> // UNIQUE VIOLATION
> case 23505: return extractUsingTemplate("violates unique constraint \"","\"", sqle.getMessage());
> // FOREIGN KEY VIOLATION
> case 23503: return extractUsingTemplate("violates foreign key constraint \"","\"", sqle.getMessage());
> // NOT NULL VIOLATION
> case 23502: return extractUsingTemplate("null value in column \"","\" violates not-null constraint", sqle.getMessage());
> // TODO: RESTRICT VIOLATION
> case 23001: return null;
> // ALL OTHER
> default: return null;
> }
> } catch (NumberFormatException nfe) {
> return null;
> }
> }
> };
> ------ EOF ------
> My problem ist that sqle is a BatchUpdateException and not the suspected PSQLExpection.
> BatchUpdateException message doesn't contain the constraintName!
> I sloved that by adding
> "SQLException psqle = sqle.getNextException();"
> and replace the "sqle.getMesage()" with "psqle.getMessage()"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list