0 Replies Latest reply on Jun 19, 2006 6:13 AM by Zaid Omar

    @MapKey value is not populated to the child entity

    Zaid Omar Newbie

      Hello,

      Under jboss-4.0.4.GA, @MapKey seems not working properly with EJB 3.0, the key of the map is not populated to the child when persisted.

      After executing the following code:

      Dock dock=new Dock();
      DockI18nName dockI18nName=new DockI18nName();
      dockI18nName.setName("test");
      dock.getNames().put("ar",dockI18nName);
      ...
      em.persist(dock);

      The value "ar" is not persisted in the language_id column in the db table, instead it is set to null

      Anybody knows whats the problem ? or its a bug ?

      the Entity classes are as follow:


      @Entity
      @Table(name="docks")
      public class Dock{
      private Map<String,DockI18nName> names=null;

      @OneToMany(cascade={CascadeType.ALL})
      @JoinColumn(name="bird_id")
      @MapKey(name="languageId")
      public Map<String, DockI18nName> getNames() {
      return names;
      }
      .............................
      }


      Entity
      @Table(name="docks_i18n_names")
      public class DockI18nName {
      private Long id=null;
      private String languageId=null;

      ................}


      Regards,
      Zaid