Play Slick with Oracle
Posted by Piotr Limanowski on .Working with Oracle database never is a pleasure. Right on from the environment setup till the very first CRUD operations. Yet often times we're forced to do so. As I haven't found one, here's a quick guide on how to integrate Oracle into Play/Slick app.
Dependencies
Oracle is supported via a closed-source slick-extensions plugin from Typesafe that wraps JDBC driver. Pull it into your build by adding slick-extensions library and appropriate version of play-slick module to your build:
Configuration
In Play application.conf file set your database connection settings to (whereas default is db name):
Usage
In your model classes import com.typesafe.slick.driver.oracle.OracleDriver.simple._
and you’re good to go.
Known Issues
A known issue with Oracle database is that whenever passing an empty value or nothing with an AutoInc index the db complains. To solve the issue you must provide the value which effectively means no AutoInc at all. Thus, I employed a simple solution of creating a spin-off data object without the id (and in most cases it is also my domain object as I usually don’t need ids) and then map it into the DB-compatible one. For the last task you might use a type class (I would not recommend using implicit conversion).