Skip to content

How to create a new JDBC back end

John Sullivan edited this page Feb 7, 2017 · 4 revisions
  • First, try the SQLite back end. You can set longevity.jdbc.driverClass to be whatever you want.
  • Wait for something to go wrong. (If you are going to be using optimistic locking, something silly is going to go wrong pretty early on. Other than this, I can't think of anything that will go wrong, but something probably will.)
  • Talk to us about it on the message board or on Gitter.
  • Add your back end into the build
    • Add your driver as a ModuleId into project/Dependencies.scala
    • Add your driver as both an optional and test dependency in the longevity project in build.sbt
    • Create an SBT sub-project longevityYourBackEndDeps that mirrors longevitySqliteDeps
    • Add your SBT sub-project to the aggregate clause for the root project
  • Add a new longevity.config.BackEnd for your JDBC driver.
  • Copy the entire package longevity.persistence.sqlite into longevity.persistence.yourBackEnd. rename everything from SQLite to YourBackEnd accordingly. (Including in the scaladoc.)
  • Copy/paste SQLite code in longevity.persistence.RepoPoolBuilder to 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.jdbc need to be changed to fix your problem. Your fixes are most likely going to diverge from what is needed by SQLite. So push down the code in question into SQLiteRepo and YourBackEndRepo, leaving behind something abstract in JdbcRepo.
  • 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 BackEnd, 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 clear problems, I typically start with test-only longevity.integration.domain.basics.*.
  • There are some tests that you will have to add - see specifically:
    • longevity.integration.duplicateKeyVal
    • longevity.integration.poly
    • longevity.integration.queries
    • longevity.integration.unstablePartitionKey
    • longevity.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!