public boolean add(Hello a) {
try {
Trans.exec(new Atom() {
public void run() {
dao.insert(a);
B b =a.getB();
dao.insert(b);
//流程
List<Pojo> pojoList = a.getPojoList();
try {
dao.insert(pojoList );
} catch (Exception e) {
throw new RuntimeException("异常了");
}
}
});
} catch (Exception e) {
return false;
}
return true;
}
异常提示:For example:> "INSERT INTO Pojo(id,name,type,text,startTime,endTime,td) VALUES('a2a5ab14e6454c20a2bfa865ab518373',' ',' ',' ','2017-04-24 00:00:00','2017-04-25 00:00:00',29) "
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'a2a5ab14e6454c20a2bfa865ab518373' for key 'PRIMARY'
try的地方报错,但前面的数据还是插入成功了