• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

quick question on primary key

 
Bob Walker Jr
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB spec says that a primary key must be a legal Value Type in RMI-IIOP. How do I know what are legal Value Types in RMI-IIOP? Is there a list somewhere?
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, that one bugs everybody... the fact that the spec requires you to adhere to RMI-IIOP types, but does not include the details.
So, I have two points on this:
1) On the exam, you DO have to know that you are required to assume RMI-IIOP. But, when answering questions -- you can treat RMI-IIOP as though it were plain RMI over JRMP. In other words, if you know the rules for RMI, you'll be able to answer the questions correctly. WITH ONE EXCEPTION: you DO have to know about PortableRemoteObject.narrow() for the remote home stub.
2) But for the curious... the restrictions that RMI-IIOP adds over RMI over JRMP are quite subtle (although they could kill you if they came up)... I pulled this directly from the RMI-IIOP programmer's guide:

* Don't inherit the same method name into a remote interface more than once from different base remote interfaces.
*Be careful when using names that differ only in case. The use of a type name and a variable of that type whose name differs from the type name only in case is supported. Most other combinations of names that differ only in case are not supported.
There are other restrictions, but I think these are really the two big issues that matter for EJB. But as I said, this is not on the exam
cheers,
Kathy
 
Bob Walker Jr
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, Kathy. So can primitive types be used as a primary key or you have to use wrappers?
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You definitely have to have a wrapper... everything requiring a primary key is of type Object
cheers,
Kathy
 
Forrest Xu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a legal Value Type in RMI-IIOP could be Serializable Type, primary wrapper object and then what? does it include remote type?
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy -- a legal type for args and return types for Remote methods in EJB could be Serializable, primitives, Remote objects, and arrays or collections of any of those, even if you use type Collection, which is *not* Serializable, but all of the collections implementation classes in the API are Serializable.
Almost. There used to be a little problem, don't know if they've fixed it, that for some STUPID reason the collection returned from the values() method on a hashtable (maybe hashmap too, can't remember) was NOT in fact Serializable. This brought our little project to its knees once, 'till someone looked at the source code for the hashtable/map class and found that the collection returned was from an implementation of an inner class that was not, to our horror, Serializable!
OK, sorry for the getting a little excited there. But if you use any of the known, exposed collections in J2SE, there's no problem.
cheers,
Kathy
 
Forrest Xu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,Kathy,
Thanks,
Now I think I understand it very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic