2 Replies Latest reply on Nov 17, 2005 7:04 AM by epbernard

    List index when mapping a List

    rwallace

      I'm trying to map the follwing class with a ManyToMany annotation:

      @Entity
      public class Book {
      
       protected List<Contact> m_authors = new ArrayList<Contact> ();
      
       public List<Contact> getAuthors () {
       return m_authors;
       }
      
       public void setAuthors (List<Contact> authors) {
       m_authors = authors;
       }
      }
      


      In Hibernate, you could specify the column to use for the list index with <list-index column="authorIndex" />, but I can't see any way to specify a list index with EJB3 annotations. Is this possible?

        • 1. Re: List index when mapping a List
          rwallace

          Sorry, forgot to add the annotations. It should be:

          @Entity
          public class Book {
          
           protected List<Contact> m_authors = new ArrayList<Contact> ();
          
           @ManyToMany(fetch = FetchType.LAZY)
           @JoinTable(table = @Table(name = "revman_book_authors"),
           joinColumns = {@JoinColumn(name = "bookId")},
           inverseJoinColumns = {@JoinColumn(name = "authorId")})
           public List<Contact> getAuthors () {
           return m_authors;
           }
          
           public void setAuthors (List<Contact> authors) {
           m_authors = authors;
           }
          }
          


          • 2. Re: List index when mapping a List
            epbernard

            @IndexColumn