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.
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 ]
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 ]
Keith Rosenfield<br />SCJP<br />SCWCD<br />SCBCD
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop