1
来验证我的实体bean我已经创建了我的豆这里面的验证方法@PreUpdate不返回正确的异常信息
@PrePersist
@PreUpdate
public void validate(){
if (startTime.after(stopTime)) throw new ValidationException("Wrong order");
}
的ValidationException是这样的:
@ApplicationException(rollback = true)
public class ValidationException extends RuntimeException {
public ValidationException(String message) {
super(message);
}
}
如果我尝试与
try {
timeframefacade.create(timeframe);
} catch (Exception e) {
System.out.println(e.getMessage());
e.getMessage创建一个bean()返回 “错误的顺序”,这是正确
try {
timeframefacade.edit(timeframe);
} catch (Exception e) {
System.out.println(e.getMessage());
它返回“事务异常中止”,这是一个EJBException。我如何获得与上面相同的结果并避免所有日志记录,这也会发生?
完美,非常感谢。希望flush操作不会对编辑的其余部分产生任何负面影响...... – user1720222 2013-04-07 13:30:20
还有一件事,如果您仍然阅读:创建命令(持续)后,记录器保持不变,如果捕获到异常,然后在编辑命令(合并,刷新)之后,将整个printstack写入控制台。你知道如何避免这种情况吗? – user1720222 2013-04-08 13:29:31