Forums Register Login

head first EJB question

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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 ]
I don't like that guy. The tiny ad agrees with me.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 553 times.
Similar Threads
Why Map doesn't extend collection interface while List and Set can extend Collection interface
Best Pratice of Collection Framework
FindByXXX( ) method in Entity beans
interface overrides in Java Collection API
Root Interfaces for Collection
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 04:00:44.