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
source share