-
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.driverClass
to 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
ModuleId
intoproject/Dependencies.scala
- Add your driver as both an optional and test dependency in the
longevity
project inbuild.sbt
- Create an SBT sub-project
longevityYourBackEndDeps
that mirrorslongevitySqliteDeps
- Add your SBT sub-project to the
aggregate
clause for theroot
project
- Add your driver as a
- Add a new
longevity.config.BackEnd
for your JDBC driver. - Create package
longevity.persistence.yourBackEnd
, and addYourBackEndRepo
,DerivedYourBackEndRepo
, andPolyYourBackEndRepo
. SeeSQLite
equivalents of these classes for an example. - 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 other JDBC drivers. Have your repo classes overrideJdbcRepo
behavior appropriately.- Consider overriding
JdbcRepo.convertDuplicateKeyException
so you get longevity exceptions for these that contain the violated key. See the override inSQLiteRepo
for 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
BackEnd
tolongevity.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.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!