When using the EntityManager find method to lookup an Entity by primary key is
doesn't throw the EntityNotFound exception when it doesn't find the entity.
This was a bug in the non-embedded version a long time ago, and has since been
fixed.
My code that proved that the exception was not being thrown is as follows:
| public JBossProject findProject(String projectId) throws
ProjectNotFoundException {
|
| JBossProject project = null;
|
| try {
| project = (JBossProject) entityManager.find(JBossProject.class,
projectId);
| } catch (EntityNotFoundException projectNotFound) {
| StringBuffer message = new StringBuffer("Could not find project ");
| message.append(projectId);
| message.append("!");
| System.out.println("Hey, I caught the EntityNotFoundException, and
I will throw the ProjectNotFoundException!");
| throw new ProjectNotFoundException(message.toString(),
projectNotFound);
| }
|
| return project;
|
| }
|
The System.out.println above never executed. Instead null was returned from
the method with no exception.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929475#3929475
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929475
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user