Apache Cayenne Documentation > Documentation > Cayenne Guide > Customization > Custom DbAdapter
How do I write an adapter to support a database that is not yet supported?
You need to implement a custom DbAdapter
. Most likely you won't have to do it from scratch and can extend a JdbcAdapter or one of the existing db-specific adapters.
If the adapter is for a database that we currently do not support and you are planning to donate it to Cayenne, you can do this first:
- Open a JIRA issue where all contributed code will go.
- Subscribe
to the developer mailing list and introduce yourself to Cayenne developers.
Implementation procedure is roughly the following:
- Check out
the latest Cayenne source from SVN. If you use Eclipse, follow these instructions
to setup the projects.
- Create a barebone adapter that inherits from JdbcAdapter.
| It is a good idea to put all new adapter code in its own Java package, e.g. org.apache.cayenne.dba.mydb, as default resource loading depends on that. |
- Copy types.xml file from org.apache.cayenne.dba package and edit it to map standard JDBC types to the target database native types.
| Correct mapping is needed for the Modeler to do schema generation. Technically it is not required for the runtime. However types.xml should still be there. |
- Run existing Cayenne unit tests
with the new adapter, analyze the failures and change adapter code accordingly. - Repeat the last step until all tests pass.
- Report success in JIRA and the dev list - one of the committers will integrate your code to Cayenne.