-
Notifications
You must be signed in to change notification settings - Fork 6
How to create a new JDBC back end
John Sullivan edited this page Feb 8, 2017
·
4 revisions
- First, try the generic JDBC back end. You can set
longevity.jdbc.driverClassto be whatever you want. - Wait for something to go wrong. If nothing goes wrong, JDBC back end should be fine for you.
- If something goes wrong, talk to us about it on the message board or on Gitter.
- Add your back end into the build
- Add your driver as a
ModuleIdintoproject/Dependencies.scala - Add your driver as both an optional and test dependency in the
longevityproject inbuild.sbt - Create an SBT sub-project
longevityYourBackEndDepsthat mirrorslongevitySqliteDeps - Add your SBT sub-project to the
aggregateclause for therootproject
- Add your driver as a
- Add a new
longevity.config.BackEndfor your JDBC driver. - Create package
longevity.persistence.yourBackEnd, and addYourBackEndRepo,DerivedYourBackEndRepo, andPolyYourBackEndRepo. SeeSQLiteequivalents of these classes for an example. - Copy/paste SQLite code in
longevity.persistence.RepoPoolBuilderto your back end.- There is a lot of duplication in this source file! If you could help us clean this up we would greatly appreciate it!
- Now, figure out which parts of
longevity.persistence.jdbcneed to be changed to fix your problem. Your fixes are most likely going to diverge from what is needed by other JDBC drivers. Have your repo classes overrideJdbcRepobehavior appropriately.- Consider overriding
JdbcRepo.convertDuplicateKeyExceptionso you get longevity exceptions for these that contain the violated key. See the override inSQLiteRepofor an example.
- Consider overriding
- Run the tests. You will need to have MongoDB and Cassandra installed for them to run. See the Developer Setup page for details.
- By virtue of adding your own
BackEndtolongevity.config.BackEnd.values, a lot of the tests will pick up your back end automatically. If you get a lot of errors and want to narrow things down a bit to start clearing problems, I typically start withtest-only longevity.integration.domain.basics.*. - There are some tests that you will have to add - see specifically:
longevity.integration.duplicateKeyVallongevity.integration.polylongevity.integration.querieslongevity.integration.unstablePartitionKeylongevity.integration.writeConflict
- It would really be nice if more of these tests would just automatically adapt to a new back end. If you could add that in for us, we would be eternally grateful!