Mapping from abstract schema to a real database
Sooner or later, you have to tell the Container how and where to manage your persistent data. This happens outside the deployment descriptor, in a vendor-specific way. That means, of course, that you’re not tested on it in the exam. Every vendor has their own mechanism, but you’ll usually get some sort of a GUI where, if you’re lucky, you can tell the Container to connect to a specific database, and then you’ll drag and drop or draw connections from CMP fields to columns in one or more tables.
Because this mapping happens outside of EJB, in the server, there’s not much we can say about it. The part we’re most interested in is mapping from abstract queries to REAL queries, and that happens in a very cool way, using a vendor-independent query language just for your entity bean queries, EJB-QL. We’ll look at that on the next page.
Writing your portable queries, for select and finder methods
EJB-QL is a portable query language that lets you write SQL-like statements write into the deployment descriptor! You put them in the XML and without having to know anything about the real database.
As a Bean Provider, you can happily write all the queries you want, trusting that the Deployer will, in the end, map your CMP fields to real tables and data. All ...