An entity bean is an enterprise bean that represents data that is typically stored in a database. Entity beans are part of the EJB 2.1 specification and are used in J2EE 1.4 enterprise applications. In Java EE 5 enterprise applications, you use the Java Persistence API to interact with databases.
Each entity bean represents a set of data, such as the fields in a database record. Each instance of the entity bean contains one element of that data, such as a row from a database table.
There are two types of persistence for entity beans:
Methods of the entity bean's home interface enable a client (any user of the bean) to find entities already in the database and insert new entities into the database. These methods are defined in the J2EETM specification.
Entity beans can be shared by multiple clients. Because the clients might want to change the same data, entity beans should use transactions. Typically, the EJB container provides transaction management.
The state of an entity bean is saved in a storage mechanism, such as a database, making the state persistent. Persistence means that the entity bean's state exists beyond the lifetime of the application or the J2EE server process. The data in a database is persistent because it still exists even after you shut down the database server or the applications it services.
You should probably use an entity bean (rather than a session bean) under the following conditions: