This content has been marked as final.
Show 2 replies
-
1. Re: Finding an entity using a non-@Id unique identifier
pmuir Aug 22, 2007 5:32 AM (in response to uke)You could override the find() method on EntityHome in your employeeDao
-
2. Re: Finding an entity using a non-@Id unique identifier
uke Aug 22, 2007 7:18 AM (in response to uke)Thanks for your response!
I tried overriding the find()-method with the following:@Override public Employee find() { EntityQuery eQuery = (EntityQuery)Component.getInstance("employeeIdByEmploymentNumber"); Long l = null; if(eQuery.getResultCount() > 0) l = (Long)eQuery.getSingleResult(); getEntityManager().joinTransaction(); Employee result = getEntityManager().find( getEntityClass(), (l == null ? getId() : l)); if (result==null) result = handleNotFound(); return result; }
I then aimed the commandButton towards /viewEmployee.xhtml, and added to the -tag for it, but it gives me LazyInitializationException and TransientObjectException.
I wasn't really sure on what to do with the overridden find method, since I'm not really sure why my session is closed, and why it works when I reload the page.
Thanks
uke