Differences between entity beans and session beans in J2EE

Source: Internet
Author: User

A session bean represents a short session with the client program and may perform database read/write operations. A session bean may call JDBC by itself, or it may use entity bean to complete this call. In this case, the session bean is the customer of the Entity Bean. The domain of a session bean contains the session state and is short-lived. If the server or client program crashes, the Session Bean will be lost. This mode is usually used in database programming languages such as PL/SQL.
An entity bean represents the data in a database and the method that acts on the data. In the employee information table of a relational database, each row is represented by a bean. Entity beans are transactional and long-lived. Entity Bean exists as long as the data stays in the database. This mode can be easily used in relational databases, not just object databases.
Session beans can be stateful or stateless.
A stateful Session Bean contains the session status that represents the client program. The session state is the domain value of the Session Bean instance plus all objects referenced by these domain values. Stateful session beans does not represent data in a persistent data storage, but it can represent a client program to access and update data.
Stateless session beans are not used for any status information of a specific client program. They are usually used to provide server-side behavior that does not maintain any specific State. Stateless session beans requires fewer system resources. An example of a stateless Session Bean is a service object that provides a general service or a shared view that represents the stored data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.