Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

head first EJB question

 
Bin Lu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is qustion in head first EJB p362, No.1
When implementing a one-tomany relationship, the java/util.List interface not be used.
the answer: "Only Collection or Set can be used".
My question, the List IS a collection.
Set and List both implement or extends Conllection interface.
 
David Harrigan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True,
But the EJB 2.0 spec, page 130, footnote 10 says:

We expect to include java.util.List and java.util.Map in a later version of this specification.

So, not yet, and it's not in the 1.4 spec either. Perhaps it has something to do with Lists allowing duplicate entries (and lots and lots of nulls) but Sets must have at most one null and no duplicates.
-=david=-
[ January 10, 2004: Message edited by: David Harrigan ]
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Bin:
Keep in mind that, when using container-managed persistance, the entity bean class is abstract and that the container will create the implementation class. The container is free to use any Collection or Set type of its choosing for the implementation's finder and select methods' return values. If you declare the return type to be java.util.List you will be restricting the Collection type that the container can choose, so therefore it is not permitted.
Entity beans using bean-managed persistance do not have such a restriction.
Hope this helps.
[ January 10, 2004: Message edited by: Keith Rosenfield ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic