February 2017
Beginner to intermediate
1100 pages
25h 19m
English
Let's bring together everything that we have seen and build a data-mapper class for fetching Physicist objects from the database. These classes (also called data access objects) are useful to decouple the internal representation of an object from its representation in the database.
We start by defining the Physicist class:
// Physicist.scala case class Physicist( val name:String, val gender:Gender.Value )
The data access object will expose a single method, readAll, that returns a Vector[Physicist] of all the physicists in our database:
// PhysicistDao.scala import java.sql.{ ResultSet, Connection } import Implicits._ // implicit conversions object PhysicistDao { /* Helper method for reading a single row */ private def ...Read now
Unlock full access