Java – stateful session beans and persistent entities

Stateful session beans are usually illustrated by implementing shopping carts From outside Java EE, I prefer to use persistent model entities to deal with this state: shoppingcart objects with products and quantities In this way, my state is maintained by the database and all my other states rather than the application server

What are the technical advantages of stateful session bean design over "normal" persistence? Are shopping carts in Java EE based web applications usually written using SFSB, or are they just written in other systems through finer domain modeling?

Solution

There are several ways to implement a shopping cart The main difference between SFSB and DB persistence is persistence:)

Stateful session beans will "persist" data only during the session Therefore, if the user session becomes inactive (for example, after 30 minutes of inactivity), the shopping cart is reset

Using database persistence, the shopping cart will be permanently stored. Therefore, if the user has a full shopping cart, do not visit the online store within 6 months. If you visit it again, the shopping cart will still be filled

I think the first solution is usually used because involving a non - memory database is not a good idea to store volatile data For data that does not require long-term persistence, there will be a lot of hard disk I / O overhead

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>