• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

persistent CMP fields

Ranch Hand
Posts: 77
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !

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.
    Bookmark Topic Watch Topic
  • New Topic