From the course: Java EE 7: Enterprise JavaBeans (EJB)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Stateful session bean

Stateful session bean

From the course: Java EE 7: Enterprise JavaBeans (EJB)

Start my 1-month free trial

Stateful session bean

- [Instructor] Now let's take a look at a Stateful Session Bean. A Stateful Session Bean could handle similar code like the one we've done before, however the major difference is how does the status handle and who can access the same data. But in the case of Stateful Session Bean an instance is created per client where the data is held as long as the session in between the client and EJB container isn't terminated. Therefore, this could be used for a list of your favorite artists. Let's take a look at how this looks like in code. So let's go ahead and create a Stateful Session Bean. So what you need to do is right lick on vinylApp-EJB again, select New, and this time what we're going to do is select one of the options in here as opposed to Do Other. So let's select Session Bean and do Stateful, and select the package EJB, and click Finish. And what you have here is a new Session Bean which is basically your Stateful Session Bean. So the way to determine if it's the Stateful one, you…

Contents