代码如下:
try {
// 省略。。
num = session.insert("insertUserInfo", info);
// 省略。。
} catch(PersistenceException e){
if(e.getCause()!=null && "java.sql.SQLIntegrityConstraintViolationException".equals(e.getCause().getClass().getName())){
// 唯一约束异常
}else {
// 其他异常
}
}catch (Exception e) {
// 其他异常
} finally {
// 省略。。
}