[jboss-user] [JBoss Seam] - Re: @Filter example

anescu do-not-reply at jboss.com
Tue May 15 05:51:48 EDT 2007


"fernando_jmt" wrote : 
  | 3.- Set somewhere a value for #{currentAccessLevel}.
  | 
  |   |         Contexts.getSessionContext().set("currentAccessLevel", bestRole.getAccessLevel());
  |   | 
  | 
  | 4.- Finally use the filtered Persistence Context.
  | 
  | 
  |   | @Name("nodeDAO")
  |   | @AutoCreate
  |   | @Transactional
  |   | public class NodeDAO {
  |   | 
  |   |     // Most of the DAO methods use this
  |   |     @In protected EntityManager restrictedEntityManager;
  |   | ...
  |   |  public Node findNode(Long nodeId) {
  |   |         restrictedEntityManager.joinTransaction();
  |   |         try {
  |   |             return (Node) restrictedEntityManager
  |   |                     .createQuery("select n from Node n where n.id = :nodeId")
  |   |                     .setParameter("nodeId", nodeId)
  |   |                     .getSingleResult();
  |   |         } catch (EntityNotFoundException ex) {
  |   |         } catch (NoResultException ex) {
  |   |         }
  |   |         return null;
  |   |     }
  |   | 
  |   | }
  |   | 
  |   | 
  | 

So, i did steps 1 and 2, on no 3 i have an @Out(required = false, scope = ScopeType.SESSION) which should work, but how do I use step 4? I am using a Seam generated project, i can't find anywhere a entityManager, everything is done by Seam. I suppose i have to override a method, but hell if i know which one :(.

Also, now, i tried to deploy with the code i have, i just defined my entityMAnager with this:

<core:filter name="hubFilteredChannels">
  |         <core:name>hubFilteredChannels</core:name>
  |         <core:parameters>
  |             <key>currentHub</key>
  |             <value>#{currentHub}</value>
  |         </core:parameters>
  |     </core:filter>
  | 
  |  <core:managed-persistence-context name="entityManager"
  |                                       auto-create="true"
  |                                       persistence-unit-jndi-name="java:/entityManagerFactory">
  |         <core:filters><value>#{hubFilteredChannels}</value></core:filters>
  |     </core:managed-persistence-context>

And now i get an error when loading the first page:

anonymous wrote : Caused by: org.hibernate.HibernateException: Filter [hubFilteredChannels] parameter [currentHub] value not set

So what is wrong? Why does Seam loads everything on startup??? If I have a bad page I cannot see a thing, the page redirects me to the debug page...


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4045733#4045733

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4045733



More information about the jboss-user mailing list