Discussions

EJB programming & troubleshooting: Passing Value object in ejbCreate method of EntityBean

  1. Hi,
       Is it a valid way to pass the value object in ejbCreate()in CMP.
    Thanks in advance.

    Regards
    Samy
  2. Ya, it works fine..[ Go to top ]

    Hi Samy,
    Ya, you can pass Value Object in ejbCreate() of entity.But it makes your entity dependent on your Value Object class.
    Anyway, its not considered as good design pattern.

    Regards
    Anand
  3. It used to be common practice to pass in a DTO as a parameter for the constructor in an entity bean. As Anand stated in his response, that leads to tight coupling between the entity bean and the DTO (value object).

    Check out Floyd's recommendations on DTOs and DTOFactory(s) in his EJB Design Patterns book.