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
Post a Comment