EJBコンテナを例外処理は、次の2つの方法で例外を考慮 -JAVA EE - EJB/CDI/JPA:
アプリケーション例外を - ビジネスルールに違反しているか、ビジネスロジックの実行中に例外が発生した場合。
システム例外 - ビジネスロジックまたはビジネスコードに起因しない例外。 RuntimeException、RemoteExceptionがSystemExceptionです。たとえば、EJBルックアップ時のエラーです。 RuntimeException、RemoteExceptionがSystemExceptionです。
- >これは私が私のタマン・ロジックをチェック例外を使用する必要があることを意味していますか?このような ?
private void checkConstraints(Object object) throws ValidationException{
Set<ConstraintViolation<Object>> constraintsAdress = this.getValidator().validate(object);
if(!constraintsAdress.isEmpty()){
String fullErrorConstraint = "";
for (ConstraintViolation<Object> constraint : constraintsAdress) {
fullErrorConstraint = fullErrorConstraint + constraint.getMessage() + "\n";
}
throw new ValidationException(fullErrorConstraint);
}
}
@Override
public long addCafe(Cafe cafe) throws ValidationException, DBException{
this.checkConstraints(cafe.getAddress());
for(FootballMatch footballMatch: cafe.getNextMatchesToWatch()){
this.checkConstraints(footballMatch);
}
this.checkConstraints(cafe);
this.getManager().persist(cafe);
return cafe.getCafeID();
}
けど...
ApplicationExceptionを注釈は例外クラスに適用され、真のロールバック要素の値で指定されていない限り、アプリケーション例外が自動的にロールバックのためにトランザクションをマーキングにはなりません...
私は完全にもうそれを理解していない... は、使用することをお勧めします:
- @ApplicationException(rollback = true)?
- また、未確認の例外を作成するためにこのファイルを使用できますか?
予めThxを 乾杯トム