title: How to use Future in database access
body: <p>I'm using slick in a mixed Java/Scala program.<br>
  The Java code needs to get some data from the database. <br>
  As I understand, the recommended way is to get a Future from the database, but how do I proceed from here? Am I forced to wait for the result (using blocking Await.result)? can I make the Java act similarly to Scala with onComplete?</p>
  
  <p>current (blocking) code:</p>
  
  <p>slick [Scala]:</p>
  
  <pre><code>def getUser(email: String): Option[User] = {  
      val findUser = users
          .filter(_.email === email)
          .result
          .headOption
  
      Await.result(db.run(findUser), Duration(1000, "millis")) // blocking :-(
  }
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>if(UsersDataBase.getUser(email).isDefined()) {
  ...
  }
  </code></pre>