java - How to check what constraint has been violated? -


i'm used check if user try store valid data cathcing consratinviolationexception, that:

try {     //persisitng db }  catch (constraintviolationexception e){     //print message } 

i'm using postgresql , i'm under isssue persisitng can violate more 1 different constarints. how can distiguish in catch clause constraint has been violated?

i need that, because message programm print depending on that.

something below

catch (constraintviolationexception conex) {             if (conex.getconstraintname().contains("xyz_fk")) {                 //todo project entity violating it's constrain             }              logger.info( "my log message", conex.getconstraintname());             logger.error( "my log message", conex); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -