2 Replies Latest reply on Mar 30, 2006 7:33 PM by Emmanuel Bernard

    Initializing a new entity bean with relations

    treespace Novice

      I have a new entity Author and want to add a Book. The book list is empty which generates an exception in author.getBooks().add( new Book() ). Two questions.

      First, can any old List implementation be used to initialize the list? My impression was that was a special implementation of List with a plain old List interface.

      Second, what is the best-practice in terms of initializing? Should the Author's books field new its own ArrayList? Will the loader use that or create another?

      
      public class Author
      {
       private List<Book> books = new ArrayList<Book>();
       ...