Hi,
I'm developing a J2EE application with EJB and Hibernate in JBoss.
The Member class is POJO, whose assignGroup method may throw InvalidGroupException.
public class Member {
...
public void assignGroup(String group) throws InvalidGroupException {
...
}
}
In an EJB method, it loads a Member object from Hibernate session then call the assignGroup method. Naturally, it has to catch InvalidGroupException.
Member member = (Member) session.load(Member.class, memberID);
try {
member.assignGroup(group);
} catch(InvalidGroupException ex) {
...
}
When I test it by assigning an invalid group, it cannot catch InvalidGroupException. Instead, java.lang.reflect.InvocationTargetException is thrown. InvalidGroupException is wrapped inside the InvocationTargetException, i.e. InvocationTargetException.getCause() gives InvalidGroupException.
Is that Hibernate uses a different mechanism of exception handling?
Thanks for your help.
|