4 Replies Latest reply on May 31, 2007 1:14 PM by Gavin King

    Problem with injection

    thierry rietsch Newbie

      Hi all

      I have a problem with injection.

      I have an interface called SearchCriteria and three classes (Entities) which implement this interface. Additional I have an EJB which saves the entities in the database. The search criteria gets injected into the bean from the facelet. Therefor I have three facelets which cover the fields of the entities. All this facelets call the EJB.save() methods and pass the search criteria object.

      Now I figured out, that I need to annotate the entity (@Name("..")) the same as the field name in the EJB is named (else other facelets and beans don't work. Is this correct?). This leads me into a problem as I have three different annotations for the names of the entities but one field name in the EJB which saves the entitites. How can I solve this?

      -> In the EJB save method, I compare an enum value to figure out what kind of object it is. Then I cast it to the right class and persist it then with the entity manager. I know that using a command pattern would be the better way (figured it out just a few minutes before), but this wouldn't change my problem.

      Thanks for your help and your answers,