• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object State lost in Stateful Session Bean?

 
Thorsten Mueller
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have a RequestScoped backing bean that has a reference to a stateful session bean which is responsible for holding state with the client like this:


[at]ManagedBean
[at]RequestScoped
public class MyController
{


[at]EJB
ClientSession clientSession;


public void createClient(){
clientSession.createClientEntity();
}

....
}




[at]Stateful
public class ClientSession
{

// a reference to the clientFacade to access the database
[at]EJB
private ClientFacade clientFacade;

private int id;
private Client clientEntity;

public void createClientEntity(){
// create client object
clientEntity = new Client();
clientEntity.setId(id);
// save object in database
clientFacade.create(clientEntity);
}

...

}


Now when I am invoking the "createClient()"-method in the JSF which is backed by MyController, the ClientSession succesfully creates a new clientEntity object and also persists it to the database. However, when I refresh the page, only the id (primitive integer) is maintained and the clientEntity object is null. Why does the Stateful bean forget the state of the object?

Best Regards,
Thorsten




 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!