This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Stateful Bean

Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 2 questions:
1. What will happen if I put some parameters inside ejbCreate() for a Stateless Bean. Will it compile/deploy.
2. Suppose if I am holding a reference of a stateless bean inside a stateful bean. what will happen during passivation. Is it right to do such a thing??
Please let me know the answers to the above.
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer to your first question:
Stateless session bean can hold state, but doesn�t hold client-specific state because a client is not guaranteed to use the same session bean instance for different method invocations. The container has the freedom to swap stateless instances back and forth between clients. It means after each method invocation, the stateless EJB clears itself out from the information of the past invocations, therefore, using a stateless EJB, it does not make sense to call the create method with a parameter because immediately after the call, the parameter will be cleared. Client-independent data can be cached in a stateless bean if:
The information being cached will never change, and
The application can tolerate a copy of the same cacher repeated in each stateless bean instance that the container creates
To answer your second question:
The container preserves remote references to other beans with the conversational state when the stateful session bean is passivated. However, I do not understand why your stateful session bean refers to a stateless session bean.
    Bookmark Topic Watch Topic
  • New Topic