Configuration
SQLite is the quickest to try: the graph is a file, with no server to run. Add org.xerial:sqlite-jdbc, 3.53.2.0 or
later (an older SQLite refuses Cypher: see Supported engines), and name the file:
database: datasources: graph: type: SQLITE database-name: /var/data/app.db # the file, made if it is not thereOn Postgres, add org.postgresql:postgresql:
database: datasources: graph: type: POSTGRES host: localhost port: 5432 database-name: app user-name: app password: secretOracle takes type: ORACLE and the properties in Oracle. Without Spring, give Drivine the same
properties:
val drivine = Drivine(DataSourceMap(mapOf( "graph" to ConnectionProperties(type = DatabaseType.SQLITE, databaseName = "/var/data/app.db"))))val manager = drivine.persistenceManager("graph")The graph’s tables are made, where they are not there yet, before the datasource’s first connection, so the first
statement sent to a new store finds them, with no object manager made first. A user who may read the tables but not make
them works with a store where they are there. The tables are made committing each statement, also on a datasource whose
connections start with autoCommit = false. So is a statement run outside a transaction, through a
NonTransactionalPersistenceManager or a connection on which no transaction is begun: Drivine turns such a connection
to commit each statement as it has it, and back as it gives it back. It leaves alone a connection that is a
transaction’s of the application’s own, which Spring’s TransactionAwareDataSourceProxy hands out inside a Spring
transaction (also in a wrapper that unwraps to it), and a distributed (JTA) transaction’s: a statement run on it is
committed, or rolled back, with that transaction. A Drivine transaction on such a connection joins the application’s,
as a @Transactional method joins one it is called in (#724):
it commits nothing itself, and what it ran is committed or rolled back with the rest of the application’s transaction.
One that rolls back marks the application’s transaction to roll back at its end, so Spring’s
DataSourceTransactionManager then rolls it back and throws UnexpectedRollbackException where it was to commit; a JTA
transaction, JtaTransactionManager’s too, is marked through the TransactionSynchronizationRegistry at
java:comp/TransactionSynchronizationRegistry. JpaTransactionManager, Hibernate’s and other managers that read
only their own mark don’t read the ConnectionHolder’s, so in a Spring transaction a Drivine rollback also registers a
transaction synchronization whose beforeCommit fails the commit: such a manager then rolls the transaction back and
throws that UnexpectedRollbackException, which says a Drivine transaction that joined it rolled back. (A JPA
transaction’s connection reaches Drivine only where its JpaDialect gives the JDBC connection, as
HibernateJpaDialect does.) Under DataSourceTransactionManager the mark is read first, and Spring’s own
UnexpectedRollbackException is thrown. In earlier versions a Drivine
transaction there committed the application’s work so far as it ended, and left the connection committing each statement
after it. Nor are the graph’s tables made on a Spring transaction’s connection,
which would commit it partway: they are made on the first connection had outside one, so on a new store a Cypher
statement in the application’s transaction fails until then, with a DrivineException that says so. A graph name that
can’t name tables, such as my-graph, makes no tables: plain SQL still works, a Cypher statement fails with a
DrivineException, naming the graph and saying why, and an object manager over the graph is refused with an
IllegalArgumentException that says the same. A schema catalog for every database skips the datasource, and one that
names it fails.

