• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

FindByXXX( ) method in Entity beans

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Can anybody explain me following :
How can "Collection FindByXXX( )" method of Entity bean can work? As far as I know Collection is not a Serliazable object and method should return an RMI-IIOP compliant object.

Regards
Mini
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although Collection interface does not extends Serializable, J2SE provided concrete implmenetations of this interface e.g. ArrayList, LinkedList do implement Serializable interface.
So, it is okay to declare Collection as return type.
 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by C Chavan:
Although Collection interface does not extends Serializable, J2SE provided concrete implmenetations of this interface e.g. ArrayList, LinkedList do implement Serializable interface.
So, it is okay to declare Collection as return type.


But the spec say and HFE says that the return type of a Component interface method should RMI-IIOP compatible.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is perfectly valid to use a collection to return results, however the objects in that collection must a serializable type. For example, when I run the EJB Validator over our EAR for WebSphere, it warns that some of the return types *must* be serializable at *runtime* (e.g., we have a method that returns a List, but the things in that list are of type ArrayList, which does implement Serializable).
It's just one of those things and best to look out for it, but accept it for what it is.
-=david=-
 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Harrigan:
It is perfectly valid to use a collection to return results, however the objects in that collection must a serializable type. For example, when I run the EJB Validator over our EAR for WebSphere, it warns that some of the return types *must* be serializable at *runtime* (e.g., we have a method that returns a List, but the things in that list are of type ArrayList, which does implement Serializable).
It's just one of those things and best to look out for it, but accept it for what it is.
-=david=-


Hi David
Sorry to split the hair like this, but HFE(Head First EJB) some where says that the return type should RMI-IIOP and also says that the collection itself should be serializable in addition to the elements of the collection.
Mini.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mini,
Here is what I think. Since, the container is the one that implements finder methods, it makes sure the implementation classes of the collection that is returns are serializable.

but HFE(Head First EJB) some where says that the return type should RMI-IIOP and also says that the collection itself should be serializable in addition to the elements of the collection.

I think you are refering to page 72 of HFE when you mention this. Page 72 mentions that you should not rely on the collection returned by the values() menthod of Map classes, becuause it returns a collection, but you do not know if the implementation class of the collection is serializable. It is not something that the container is returning.
I hope this helps.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mini mehta:
HFE(Head First EJB) some where says that the return type should RMI-IIOP and also says that the collection itself should be serializable in addition to the elements of the collection.


I think the above posts are correct.
You are also right, if you examine just the Collection interface alone. That does not implement Serializable interface. But what HF EJB means is that at run time the Collection interface should denote an object that implements the Serializable interface. for example: ArrayList, Vector, LinkedList etc...
So it's words phrasing issue!... . I am sure non-english speaking candidates would also find this a bit confusing at first!....
You could write your own custom list or linkedlist implementing the Collection interface but not Serializable interface. Such Object(s) are not allowed as the return types for remote methods.
So when writing code for bean methods returning a Collection interface,
for example: Session bean methods returning a Collection, we should make sure that we select a Collection class that implements Serializable like ArrayList, Vector etc......
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic