Show TOC Start of Content Area

Background documentation Bean-Managed or Container-Managed Entity Beans  Locate the document in its SAP Library structure

When developing entity beans with bean-managed persistence, you can freely manage the persistence. That is, you can write the SQL queries yourself. This is called programmatic persistence.

You use bean-managed entity beans when:

      Your application logic requires more complex interactions with the database

      You want to use complex or database-dependent SQL queries

      The O/R mapping of the abstract schema does not fulfill the O/R mapping rules for the J2EE Engine

      You want to use a different service for persistent management.

This graphic is explained in the accompanying text

Bean-managed entity beans are more difficult to develop. If your application does not require specific coding, it is therefore recommended that you develop entity beans with container-managed persistence.

The container-managed persistence is called a declarative persistence. It is very easy to use when the object model of the persistent data is complicated. You do not have to write the SQL queries – you can use the system to generate the O/R mapping, the corresponding tables, and the SQL queries required by the persistence management that uses common JDBC types automatically. To enable the EJB Container to perform these functions, you must declare the necessary information in the bean’s deployment descriptors.

Use container-managed entity beans, when:

      You do not want to write SQL code in your beans, and prefer instead to pay more attention to the business logic of the bean.

It is easier to write container-managed entity beans because the EJB Container manages the database access, the mappings, the consistency and the integrity of the data.

      You do not need complex, database-dependent access calls to the database

      You want to have implicit (automatic) synchronization for concurrent access in the cluster (although it is also possible to use explicit locking)

      You need portable entity beans.

As the source code of container-managed entity beans (as opposed to the source code of bean-managed entity beans) does not contain database access calls, container-managed entity beans are independent of the database and can easily be ported to different databases.

 

For more information about creating entity beans, see Creating Entity Beans.

 

End of Content Area