• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

persistent CMP fields

 
Imran Vohra
Ranch Hand
Posts: 77
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Which of the following are valid types of persistent CMP fields of a 2.0 CMP entity bean?

a primitive types.
b A serializable class.
c Local interface of another EJB.
d Remote interface of another EJB.
e java.util.Collection and java.util.Set

Correct Answers are : a & b. That's ok.
But why not c & d?
Can anyone please explain that?

Thanks
Imran
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !
Just think about it. We're talking about PERSISTENT fields. Knowing what IS a reference to an EJB interface, and knowing about the pool/passivation/time out concepts of EJB, do you really think a reference to an EJB interface (remote or local) is suitable for persistence?

You ask for a bean remote stub, play with it, then you save it in your persistent store. Two months after, you come back, load your persistent bean stub and ask it to run a business method...BANG !
java.rmi.NoSuchObjectException

Don't you think your bean timed out after two monthes? Or if it's not affected by time out, do you think the EJBObject is still there around?

The trick here is that local/remote interface objects are suitable for passivation (passivatable for EJB readers . Which means when a stateful Session is passivated, the remote/local interfaces to other EJBs it may hold are passivated (who said serialized ??) and may be restored when the bean activates. But such a reference being persisted just makes no sense.

Hope it's clear.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic