0 Replies Latest reply on Jul 14, 2008 6:08 PM by Rick Kilcoyne

    HTML Picklist, Converter, and One-to-Many

    Rick Kilcoyne Newbie

      I have a @oneToMany mapping table that could be a @manyToMany, but the relationship has additional properties and @manyToMany only supports a join tables with two fields. I'm going to attempt to boil this down using simpler objects:

      Let's say I have an HTMLPicklist of State objects. The result is stored in a property of a a Master object with a property called stateMappings that is type java.util.List of StateMapping. 

      What I think I need to do is create a Converter object that converts each selected State object to a StateMapping that can be stored in MasterInstance.stateMappings. I marked this converter as @Stateless and declared an @PersistenceContext EntityManager private member to use to convert the string rep of the selected States to their associated objects.

      The StateMapping has two properties: a Master object and a State object. The Id of each State object is easy to get in the Converter.getAsObject method. The Master object instance is not as obvious to me -- it exists in my current conversation, but I'm not sure about how to get a reference to it.

      At the minimum I just need some advice that I'm on the right path here. If you have any info on how best to get a reference to my Master object instance from my Converter class, all the better.

      I hope this make sense...
      Thanks all!