Permalink
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (94 sloc) 5.85 KB

ScalikeJDBC 3.0.0 is out for Scala 2.12, 2.11 and 2.10 with new useful features including the Reactive Streams support module!

http://scalikejdbc.org/

ScalikeJDBC Logo

Topics

Support Scala 2.12/2.11/2.10 on JDK 8

ScalikeJDBC 3.0 requires Java SE 8 or higher. All libraries are built against Scala 2.12, 2.11 and 2.10.

Merging JSR-310 module into core module

Since scalikejdbc-core 3.0 can depend on JDK 8 APIs, we merged scalikejdbc-jsr310 module into scalikejdbc-core module. If you're already using time APIs, You don't need add scalikejdbc-jsr310 to your libraryDependencies anymore.

In the migration, there is no source code incompatibility to existing applications.

Reactive Streams support

Newly arrived module, scalikejdbc-streams, is an extension to support Reactive Streams to subscribe results from database queries.

https://github.com/scalikejdbc/scalikejdbc/tree/master/scalikejdbc-streams

scalikejdbc-streams is a Reactive Streams 1.0 compliant implementation. We never release without passing the existing unit tests to satisfy PublisherVerification in Reactive Streams TCK.

This library is originally assumed to be suitable for batch applications. You need to keep borrowing a connection while someone is subscribing a stream provided by scalikejdbc-streams. Be aware of the max size of connection pool and carefully monitor the state of the pool.

import scalikejdbc._
import scalikejdbc.streams._
import java.util.concurrent._
import org.reactivestreams.example.unicast.AsyncSubscriber

// Prepare a connection pool in advance.
Class.forName("org.h2.Driver")
ConnectionPool.singleton("jdbc:h2:file:./db/hello", "user", "pass")

// ------------
// publisher
val publisherExecutor = Executors.newFixedThreadPool(5)
implicit val publisherEC = ExecutionContext.fromExecutor(publisherExecutor)
val publisher: DatabasePublisher[Int] = DB readOnlyStream {
  sql"select id from users".map(r => r.int("id")).iterator
}

// ------------
// subscriber
val subscriberExecutor = Executors.newFixedThreadPool(5)
val subscriber = new AsyncSubscriber[Int](subscriberExecutor) {
  override def whenNext(element: Int): Boolean = { 
    // do something here
    log.info(s"element: ${element}")
    true 
  }
  override def whenComplete(): Unit = {
    if (executor.awaitTermination(1, TimeUnit.SECONDS) == false) {
      log.warn("Timed out while waiting for all tasks terminated")
    }
    subscriberExecutor.shutdownNow()
  }
}
publisher.subscribe(subscriber)

Changes

  • [core] #682 Use collection.breakOut by @zaneli
  • [core] #677 Use LinkedHashMap.contains instead of LinkedHashMap.keys.find by @ushjp
  • [core] #676 Add a note to NamedDB scaladocs that it should be used only once by @adamw
  • [core] #673 Avoid conflict java.lang.Object and scala.Product methods by @xuwei-k
  • [core] #668 Make closeable objects to extend java.lang.AutoCloseable by @xuwei-k
  • [core] #664 Add explicit type annotations by @xuwei-k
  • [core] #660 s/toLowerCase/toLowerCase(ENGLISH) by @xuwei-k
  • [core] #659 Improve implicitNotFound message by @xuwei-k
  • [core] #655 Update dependencies by @xuwei-k
  • [core] #652 Java9: s/newInstance()/getDeclaredConstructor().newInstance() by @xuwei-k
  • [core] #651 Java9: Avoid java.lang.Integer constructor by @xuwei-k
  • [core] #643 Fix a potential issue of thread factory in ConnectionPoolFix by @zaneli
  • [core] #636 Fix #605 cleanup for merging jsr310 module by @seratch
  • [core] #635 Throw exception with invalid connectionPoolFactoryName by @mshibuya
  • [core] #631 Closing DataSource based connection pools by @smdmts
  • [core] #629 Remove UnixTimeInMillisConverterImplicits from TypeBinder by @xuwei-k
  • [core] #625 #626 Code improvements by @xuwei-k
  • [core] #623 Fix on SQLSyntaxSupportCachedColumns by @zaneli
  • [core] #608 Fix procedure syntax warnings by @xuwei-k
  • [core] #606 Add taggedQueryCompletionListener to SettingsProvider by @zaneli
  • [core] #604 Make result.name private because name column exists very often in real apps (fixes #570) by @seratch
  • [core] #602 use collect instead of filter & map by @xuwei-k
  • [core] #603 add -target scalacOptions by @xuwei-k
  • [core] #601 Introduce unapply methods to SQL* by @iTakeshi
  • [core] #600 Fix parameters passed to TableAsAliasSQLSyntax to rawParameters closes by @takayahilton
  • [core] #596 Merge scalikejdbc-jsr310 module to scalikejdbc-core by @xuwei-k
  • [core] #594 Use length instead of size by @xuwei-k
  • [core] #593 Use nonEmpty instead of size by @xuwei-k
  • [mapper-generator] #678 Fix bug that "view" argument is unused by @xuwei-k
  • [mapper-generator] #654 Avoid ConnectionPool.singleton per a code generator by @xuwei-k
  • [mapper-generator] #592 Avoid NullPointerException by @xuwei-k
  • [mapper-generator] #591 Fix batchInsert method indent by @xuwei-k
  • [mapper-generator] Remove deprecated methods since sbt 0.13.{12, 13} by @xuwei-k
  • [streams] #640 Allow modifies to Session properties used in DatabasePublisher by @yoskhdia
  • [streams] #622 Make StreamReadySQL public by @yoskhdia
  • [streams] #619 Improve handling on occupied database resources in various cases by @seratch
  • [streams] #618 Apply more strict access modifiers under scalikejdbc.streams package by @seratch
  • [streams] #617 Remove null patterns from DatabaseSubscription, StreamResultSetIterator by @seratch
  • [streams] #616 Fix to restrict on scope of internally classes by @yoskhdia
  • [streams] #614 Introducing scalikejdbc-streams as a sub module by @yoskhdia
  • [test] #638 Add AsyncAutoRollback for ScalaTest AsyncTestSuite by @amazzeo

Enjoy writing mostly type-safe SQL and get things done!