Beans session versus persistent objects

The beans session is often illustrated by the implementation of a shopping cart. Based on external Java EE, my tendency was to handle this state with a constant model entity: a ShoppingCart object with Products and quantities. Thus, my state is maintained by the database along with all my other state, not the application server.

What are the technical advantages of a bean design session over "regular" persistence? Are shopping carts in Java EE-based web applications typically written with SFSB, or like in other systems, only through more elaborate domain modeling?

+4
source share
1 answer

There are several ways to implement a shopping cart. The main difference between SFSB and database persistence is, in fact, persistence :)

A Session bean will only “save” data during a session. Therefore, if a user session becomes inactive (for example, after 30 minutes of inactivity), the shopping cart will be reset

When you save the database, the basket will be stored permanently, therefore, if the user has a filled shopping basket, do not go to the online store for 6 months and visit it again, the cart will be filled

I think the first solution is usually used, since using a memoryless database is not a good idea for storing volatile data. There will be too much hard disk I / O overhead for data that really does not need long-term stability

+1
source

All Articles