Skip to content

Releases: susom/database

database-2.0

09 Jun 07:51
Compare
Choose a tag to compare

Java 8 features

  • Java 7 and earlier do not work with this release.
  • Deprecated DatabaseProvider.Builder.transact(DbRun) as it is not lambda-friendly and provides undesirable default transaction behavior of always commit (even on error).
  • Use transact(dbs -> ...) for commit with rollback on error, or use transact((dbs, tx) -> ...) if you want to customize rollback behavior.
  • Use Supplier<Database> rather that Provider<Database>. It works either way currently, but Provider support will be remove in a future release.

Support for Vert.x

  • Add DatabaseProviderVertx with support for the Vert.x event/worker thread model and asynchronous callbacks after the database operation.
  • The SLF4J MDC will be correctly preserved for these calls (via VertxUtil.executeBlocking() wrappers).
  • See demo/src/main/java/VertxServer.java for an example.

Batch inserts

Insert multiple rows in one statement:

  db.toInsert(...).argString("row1").batch().argString("row2").insertBatch();

The batch() call is forgiving in that you can call it before the first row, after the last row, etc. to make looping easier.

Built in database connection pooling

See DatabaseProvider*.pooledBuilder() to get it for free, or fromPool() if you want to roll your own.

Support for SQL Server

Support for HyperSQL (HSQLDB)

Configuration

There is now a Config class for managing properties from different sources. There are lots of neat little tricks you can play with filtering and mapping prefixes, but here is a very simple use case:

  String propertiesFile = System.getProperty("properties", "app.properties");
  Config config = Config.from().systemProperties().propertyFile(propertiesFile).get();
  DatabaseProvider.fromDriverManager(config).transact(...);

Logging

Generally made the logs a bit more useful and machine parseable.

  • Include the database flavor when getting the connection ("Get oracle database: ..." rather than "Get database: ...").
  • Debug log SQL respects the flavor for generating date functions, and preserves millisecond precision.
  • Named parameters with prefix "secret" are now omitted from logging. In debug SQL the value will appear as "<secret>".
  • Improve documentation for Metric and ensure the message will not contain spaces or tabs.
  • Change the log format to make it easier to parse. It now uses tabs to delimit SQL (<tab>select a from b where c=?<tab>ParamSql:<tab>select a from b where c=1) and ensures the SQL and other portions of the log message do not contain tabs.
  • Avoid printing really long values into debug SQL. String values are truncated to 4000 length by default, which can be controlled by Options.maxStringLengthParam().

Miscellaneous

  • Avoid the need for iterating the result set in most cases for queries. Introduce Row and RowHandler, and SqlSelect.query*() methods to callback per row.
  • Improve support for dynamic SQL generation. Add convenience methods Database.to*(Sql). Add Sql.argCount() and Sql.appendQuestionMarks(int) to make generating insert statements easier.
  • Add ability to access the JDBC result set metadata via Row.getMetadata().
  • Add ability to read SqlArgs and Schema table from a query result (Row). This makes is easier to implement things like saving a result to another table that is created on the fly.
  • Add support for create/update tracking, history tables, etc. to Schema.
  • Make connection access configurable on the database provider builder.
  • Now Row.getX() will pick up the next column following an explicit Row.getX(int) or Row.getX(String). Previously it always started at column 1.
  • Switch from IntelliJ annotations to jsr305 to remove a dependency.

Bugs

  • Fix time zone issues with date functions.
  • Fix DatabaseProvider.fakeBuilder() so it actually works and provide a sample (demo/src/main/java/FakeBuilder.java).
  • Make database providers stricter about prohibiting use after close().
  • Use "if exists" when dropping tables in postgres.
  • Fix return types and annotations for query*OrZero().
  • Automatically stop the Metric when you get/print the message.
  • Allow custom table clause per-flavor in Schema.Table.customTableClause().
  • Prevent defining primary key multiple times in Schema.

database-1.3

25 Jan 20:48
Compare
Choose a tag to compare
  • Add convenience class Sql for dynamically generating SQL
  • Add support for Boolean, mapping to CHAR(1) with 'Y' and 'N' values
  • Make DbRun code blocks accept Provider rather than Database for efficiency
  • Package stubs for Checker Framework to use for static type checking (prevention of SQL injection)
  • Avoid throwing an incorrect validation exception with mixed (position and named) parameters
  • Add convenience methods for reading single Long and Integer values
  • Switch Database.when() from interface to concrete type to make static type checking easier
  • Remove "generic" database flavor so we fail fast if the database cannot be identified
  • Add RowStub to make it easier to test database code without a database
  • Add Database.nowPerApp() to make testing easier (you can fake the time using this method)
  • Fix bugs with floating point number handling (within the limits of the databases; Oracle has a fluke with converting -0 to 0 and Derby pretty much does everything wrong)
  • Improve annotations to prevent bugs from ignoring important return values
  • Allow access to the configuration options for Database
  • Add some convenience methods for creating DatabaseProvider with system properties, property files, etc.

database-1.2

25 Jan 20:29
Compare
Choose a tag to compare
  • Update Database methods to clarify the action will take place later, for example toInsert() rather than insert()
  • Add convenience methods for reading results while inferring the column number (assume 1, 2, ...)
  • Improve annotations to make static type checking tools more effective
  • Fixes for fluent syntax for database specific SQL using Database.when() and otherwise()
  • Fixes for Oracle 12c, particularly with storing millisecond precision Date correctly

database-1.1

25 Jan 20:20
Compare
Choose a tag to compare
  • Support for PostgreSQL
  • Convenience methods on DatabaseProvider to utilize JNDI and DriverManager
  • Require being explicit when reading nulls from results: get_OrZero(), get_OrNull(), etc.
  • Support for inserting sequence value as primary key and returning it in one call (simulated with multiple calls on Derby)
  • Do not print parameterized SQL in logs if there are no parameters
  • Show actual null in logged debug SQL rather than SqlNull.toString()
  • New convenience method dropTableQuietly()
  • New convenience class Schema to specify and generate database tables in a portable, fluent style
  • New convenience class SqlArgs to make dynamic SQL easier to construct
  • Add a way of obtaining column names in Rows to support code that uses them with reflection to read results
  • Rename argBlobInputStream() --> argBlobStream() to be a little more concise
  • Add some missing argDate*() methods
  • Add a convenience method for reading sequence values
  • Allow mixing of positional ('?') and named (":foo") parameters within SQL
  • Various configuration options and features to make testing easier
  • More convenience methods for retrieving single column results
  • Add a method (prohibited by default) to get direct access to the Connection, for migration and compatibility- Fix Timestamp conversion bugs
  • Fix numerous problems with Float and Double handling
  • Fix date comparison problems

First Maven release

07 May 21:17
Compare
Choose a tag to compare
database-1.0

Trying to make Sonatype happy