In this exercise, you will build and examine a simple EJB that uses bean-managed persistence (BMP) to synchronize the state of the bean with a database. You will also build a client application to test this Ship BMP bean.
If JBoss is already running, there is no reason to restart it.
As in the CMP examples, the state of the entity beans will be stored in the database that is embedded in JBoss. JBoss was able to create all tables for CMP beans, but it cannot do the same for BMP beans because the deployment descriptors don’t contain any persistence information (object-to-relational mapping, for example). The bean is in fact the only one that knows how to load, store, remove, and find data. The persistence mapping is not described in a configuration file, but embedded in the bean code instead.
One consequence is that the database environment for BMP must always be built explicitly. To make this task easier for the BMP Ship example, Ship’s home interface defines two helpful home methods.
Entity beans can define home methods that perform operations related to the EJB component’s semantics but that are not linked to any particular bean instance. As an analogy, consider the static methods of a class: their semantics are generally closely related to the class’s semantics, but they’re not associated with any particular class instance. Don’t worry if this is not totally clear: Chapter ...