0 Replies Latest reply on Apr 11, 2007 10:47 AM by Patrick Krämer

    Problem with java.util.Map in Entity Bean

    Patrick Krämer Newbie

      Well, I'm a bit confused how to solve this problem:

      I have got two tables in my database:

      
      Table1:
      -----------------------
      -- locale_text --
      -- --
      -- PK locale --
      -- PK,FK test_id --
      -- text --
      -----------------------
      
      Table2:
      -----------------------
      -- test --
      -- --
      -- PK test_id --
      -- --
      -- --
      -----------------------
      


      Table locale contains text in different languages.

      Now there is only one Entity Bean for table2 which inlcudes a java.util.Map locale_text. This Map is represented by table1
      I tried to solve it with secondaryTable an @MapKey but it does not work
      EntityBean:


      @Entity
      @Table(name="test")
      @SequenceGenerator(name = "test_sequence", sequenceName = "test_id_seq")
      @SecondaryTable(name="i18n_test",
       pkJoinColumns={
       @PrimaryKeyJoinColumn(name="t_id",referencedColumnName="t_id")
       })
      public class Test implements Serializable {
      
       private static final long serialVersionUID = -8939291842604811925L;
      
       @Id
       @Column(name="t_id")
       @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
       "test_sequence")
       private java.lang.Long id;
      
       //Here is my problem
       @Column(table="i18n_test",name="locale")
       @MapKey(name="locale")
       private Map<java.util.Locale,java.util.Locale> localizedText =
       new HashMap();
      
       ....
      }
      


      Happy for any help and/or ideas

      thx