Mapping constraints for databases

Each of your Java 2 platform, Enterprise Edition (J2EE) applications (in an EAR file) can have more than one enterprise bean Container Managed Persistence (CMP) module in it. Each EJB CMP module (as a JAR file) can contain more than one CMP bean. One can configure each bean to connect to its own data source by using the different Java Naming and Directory Interface (JNDI) names of each data source.

However, there are some constraints:

  • The deployment tool only enables you to map EJB CMP beans to different databases at the EJB JAR level. There are different backend ids for different database schema mapping. The product uses the attribute backendId to distinguish database specific code. For example, the code that accesses an Oracle database is different from that accessing a DB2 database. Even for the same vendor, different versions of their products can result in different generated code.

  • At run time, WAS uses the CurrentBackendId attribute to access the correct back end related code. We can only configure the CurrentBackendId at the EJB JAR level. This means that all of the EJB CMP beans within a specific EJB JAR file (which contains all the CMR beans) must connect to the same type of data source (that is, the same vendor, same version).

  • Even though one can connect EJB CMP beans to different databases of the same type, the process fails if your connections result in a table join between tables from different databases. Various actions such as EJB Query , Inheritance support, readAhead.., and so on, can result in a table join situation.

  • The datasource needs to be an XA datasource to support multiple databases' connection within a transaction.