score:0

Accepted answer

Thanks Ygor,

I finally worked out what you were saying and got rid of the createGroup method. which of course meant I was no longer "double-typing" the case class creation and population.

Now I just have;

def getGroups(): Vector[Group] = {

    // Get the rows returned from the database.
    val dbResults = Try { selectAllFromTable("groups") }

    dbResults match {
      case Success(rs) => {
        // Create an Iterator[]
        ResultSetUtils.toIterator(rs) { rs =>
          Group(
            rs.getString("groupname")
            ...
            ...
            ...
          )
        }
      }.toVector

      case Failure(ex) =>
        Vector.empty[Group]
    }
  }

Related Query

More Query from same tag