The JDBC specification provides a great abstraction for relational database work. Still in practice some cross-database portability issues remain:
- Certain standard SQL features may not be implemented in some RDBMS.
- Certain standard JDBC features may not be supported by some drivers (batch updates, auto incremented columns, etc.)
- SQL syntax may vary across RDBMS.
- BLOBs and CLOBs are handled differently by different vendors.
- Data type definitions vary across RDBMS. Data types may have different names, size and precision.
- Vendors provide their own extensions of SQL and JDBC functionality. Taking advantage of these extensions and creating portable code at the same time is not a trivial task.
org.apache.cayenne.dba.DbAdapter interface is used in Cayenne for an additional portability layer sitting on top of JDBC. There is one generic implementation of DbAdapter provided with Cayenne (JdbcAdapter) and also a subclass of JdbcAdapter for each database that is officially supported by Cayenne. Users can create their own adapter implementations as well (some hints are given here).
Usually Cayenne detects the type of the database dynamically and installs the right adapter in runtime. However a user can enforce a specific adapter class by entering its name using "Adapter" tab in the DataNode Editor panel in CayenneModeler. Alternatively an adapter can be set on a DataNode via a method call.