Package org.hibernate.exception.spi
Class TemplatedViolatedConstraintNameExtracter
- java.lang.Object
-
- org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter
-
- All Implemented Interfaces:
ViolatedConstraintNameExtracter
public abstract class TemplatedViolatedConstraintNameExtracter extends java.lang.Object implements ViolatedConstraintNameExtracter
Knows how to extract a violated constraint name from an error message based on the fact that the constraint name is templated within the message.
-
-
Constructor Summary
Constructors Constructor Description TemplatedViolatedConstraintNameExtracter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.String
doExtractConstraintName(java.sql.SQLException sqle)
java.lang.String
extractConstraintName(java.sql.SQLException sqle)
Extract the name of the violated constraint from the given SQLException.protected java.lang.String
extractUsingTemplate(java.lang.String templateStart, java.lang.String templateEnd, java.lang.String message)
Extracts the constraint name based on a template (i.e., templateStartconstraintNametemplateEnd).
-
-
-
Method Detail
-
extractConstraintName
public java.lang.String extractConstraintName(java.sql.SQLException sqle)
Description copied from interface:ViolatedConstraintNameExtracter
Extract the name of the violated constraint from the given SQLException.- Specified by:
extractConstraintName
in interfaceViolatedConstraintNameExtracter
- Parameters:
sqle
- The exception that was the result of the constraint violation.- Returns:
- The extracted constraint name.
-
doExtractConstraintName
protected abstract java.lang.String doExtractConstraintName(java.sql.SQLException sqle) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
extractUsingTemplate
protected java.lang.String extractUsingTemplate(java.lang.String templateStart, java.lang.String templateEnd, java.lang.String message)
Extracts the constraint name based on a template (i.e., templateStartconstraintNametemplateEnd).- Parameters:
templateStart
- The pattern denoting the start of the constraint name within the message.templateEnd
- The pattern denoting the end of the constraint name within the message.message
- The templated error message containing the constraint name.- Returns:
- The found constraint name, or null.
-
-