addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Intro to Slick / Slick in the Field

Intro to Slick

Slick (part of the Typesafe stack) is a modern database query and access library for Scala, based on functional principles. It allows you to write queries as if you are working with regular Scala collections.

In this session we’ll have a deep dive into how you can use this library in real projects. How to map your tables and queries to structured objects, how to create more advanced queries with multiple joins, how to setup integration tests against an in-memory database and how you can integrate Slick with the Play Framework are all questions which will have been answered at the end of this session.


Slick in the field, learning to forget ORM

For many years developers on the JVM platform were used to ORM frameworks. Our code was filled with annotations (or worst XML configuration files). We learned how to map our classes to relational tables and deal with its peculiarities. We had big, sometimes huge graph of objects, mapped to relational tables. We brought them all to memory, changed them and let it be automagically persisted back at the end of our transactions.

In a Scala/Slick world we deal with data and persistence in a totally different way. Our model are immutable structures (case classes and tuples), nullable columns are mapped to Options (and that's cool), relations are expressed by id references instead of object associations (that's less cool). Instead of writing xml or filling our code with annotations, we write type-safe idiomatic Scala code. We compose queries in a functional style. We map and flatMap over it.

But is that good or bad? What brings Slick to the readability and maintainability of our code base? How do we test our business logic when a great deal of it is executed outside the JVM?

In this talk we'll share our experience in building real world applications with Slick. The lessons learned, the patterns and anti-patterns we went through in our journey to shift the way we were used to think about persistence.


Yennick Trevels (Intro to Slick)
Yennick is currently a Reactive Applications Developer and certified Typesafe trainer at Xplore Group, where he’s actively working with Scala, Slick and Play.
Before he started working with Scala and the Typesafe stack he had six years of experience in enterprise software development with Java and Flex. During his career, he has always been investigating best-practices and ways to broaden his development toolbox.
He is also the co-founder and project lead of the GradleFx open source project, a Gradle plugin to build Flex applications.

Site: yennicktrevels.com
Twitter: @SlevinBE


Renato Cavalcanti (Slick in the Field)

Renato Cavalcanti is an independent Scala developer based in Belgium. Coming from a totally different field (psychology), he discovered a passion for programming in 1999. Scala aficionado since 2007, he has been hacking in Scala and related technologies for fun and profit. He's the founder of BeScala and steering committee member of the BeJUG.

Site: strongtyped.io
Twitter: @renatocaval

Join or login to comment.

  • Yennick T.

    Thanks Chris for your comment!

    I'll update my presentation so that it shows the .filter method instead of the .where method.

    As for the meeting.documents structure, it actually looks like this:
    case class Meeting(...) {
    var documents: Option[Set[Document]] = None
    }

    So it's an option of documents. When it's not being loaded this stays None, but once it's loaded (even when it's empty) it becomes a Some(Set()). This way I can freely choose whether I load them or not, and when I don't it's (imo) clearly indicated by the None value.

    1 · June 5, 2014

    • Yennick T.

      Here's a Slick mapping I use for a blogpost. It has an optionally loaded author on it, which:
      * when loaded is Some(author)
      * when not loaded is None

      https://gist.github.co...­

      As you can see it doesn't bring any extra boiler plate.

      July 30, 2014

    • Jan Christopher V.

      I see. You are using a var for the relationship. Fair enough, probably not a huge problem. One more reason for tuples ;).

      July 30, 2014

  • Carlos Q.

    There is another option for DB access called: ScalikeJDBC

    ScalikeJDBC is a tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use and very flexible APIs. What’s more, QueryDSL makes your code type-safe and reusable.

    website: http://scalikejdbc.org

    June 6, 2014

    • Francis De B.

      Yep. That's the alternative I mentioned. More SQL like than the collections based slick api

      June 6, 2014

  • Jan Christopher V.

    Hi from the Slick authors! Great to see the interest in Slick. Nice slides, Yannick :)! A few added comments from us:

    .where is going to be deprecated in favor of the standard Scala .filter .

    Yannick shows a mutable meeting.document which he updates using .mapResults. We usually suggest an alternative, which is not having your case classes contain references to related rows at all, but only relate them using tuples. This decouples your loading strategy (do you load relationships or not) from your case classes.

    left/right/outer joins are indeed not very smooth right now. Improving this is on our roadmap for Slick 2.2 (expected in Q4 2014).

    1 · June 5, 2014

    • Jan Christopher V.

      A tuple is what a Slick join already returns. Or if you search the slick google group for relationships I explain it on several threads. I will add a docs section "ORM to Slick" for Slick 2.1 which will also explain it.

      June 5, 2014

    • Francis De B.

      Thanks for the update!

      June 5, 2014

  • Carlos Q.

    very interesting. slick in the field demo was a bit complex to follow, but got the main idea :)

    June 5, 2014

  • Yennick T.

    My intro to Slick slides are now available here (with code in the speaker notes): https://github.com/SlevinBE/presentations/raw/master/Slick%20-%20The%20Structured%20Way.pptx

    The recording will be posted later.

    June 5, 2014

  • Sam De B.

    Very mesmerizing presentations, though not really introductionary, hope to reflect a bit more on the slides soon?

    June 5, 2014

  • Luc D.

    Very interesting

    June 4, 2014

  • Yennick T.

    Drinks and sandwiches will be provided by Xplore Group

    2 · June 3, 2014

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy