CMR & ejbCreate


EJB design: CMR & ejbCreate

  1. CMR & ejbCreate (1 messages)


    I have two entities in a typical CMR 1:n relationship (assume customer and order). The ejbCreate of order takes a customer as a parameter.

    What's the best way to provide the customer entitiy bean in a typical web application? Currently, my web apps already knows the primary key of the customer (The customer pk is saved in the http session). The servlet passes this key to a stateless session bean that calls findByPrimaryKey of customer. How can I avoid this findByPrimaryKey? (After all I just want to insert the key of the customer into the order table - I don't need the customer for anything else here!)

    The only way around I found is to take a stateful session bean and save the customer entity bean there. But this seems even less attractive than the redundant findByPrimaryKey. (Saving in the http session is no solution since the entities are local objects and the servlet engine might run in a different VM).

    BEA WLS 6.1 allows to map a database column to a cmp and cmr field, but then the cmr field is read only. How about other EJB container?


    Threaded Messages (1)

  2. CMR & ejbCreate[ Go to top ]

    What is so unattractive about saving a stub of an entity bean in a stateful session bean? That's exactly what we do in our application - we lazily cache EJBHandle there, the session bean itself is created and attached to a session on the user's login.