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]
}
}
Source: stackoverflow.com
Related Query
- Populate a case class from a DB ResultSet
- How to convert JSON into Scala class (NOT Case class), and then populate set of case classes from that big class
- Get field names list from case class
- Instantiating a case class from a list of parameters
- Scala 2.10 reflection, how do I extract the field values from a case class, i.e. field list from case class
- Case classes inheriting from abstract class
- Read case class object from string in Scala (something like Haskell's "read" typeclass)
- Can I get a Scala case class definition from an Avro schema definition?
- Spark case class - decimal type encoder error "Cannot up cast from decimal"
- Case Class Instantiation From Typesafe Config
- Update case class from incomplete JSON with Argonaut or Circe
- How To Access access Case class field Value from String name of the field
- remove elements from a List of case class structure efficiently and elegantly
- How to fill case class from json with partial data?
- case class from Map
- Return copy of case class from generic function without runtime cast
- Is there a way to get a JSON-Schema from a Scala Case Class hierarchy?
- Scala case class arguments instantiation from array
- Extend case class from another case class
- Extracting a value of a given type from a case class
- Transforming data from a runtime storage to a case class
- Unable to create dataframe from RDD of Row using case class
- Scala: From nested case class to flatten case class
- Applying validation from HList to a case class
- Invoke a case class from a main method within an object
- Shapeless: is there a way to get Hlist type from a case class or a tuple
- scala case class copy method is unseen from java code
- Prevent Mixin overriding equals from breaking case class equality
- Sealed Trait / Object Case Class Byte Code Changed from 2.9.1. to 2.9.2?
- filter out a field from a case class
More Query from same tag
- How to check if a map contain a empty string value in scala?
- Prepending to a Scala Iterator -- timeout?
- intellij idea 13.1.4 update scala plugin to v0.41 cause permission denied
- How to select the N highest values for each category in spark scala
- sbt - include additional source directories
- Extracting project structure runs forever
- read individual elements of a tuple from a map((tuple),(tuple)) in scala
- How to access a case class' parameter from context of a trait
- Spark - Task not serializable: How to work with complex map closures that call outside classes/objects?
- Kafka topic object into spark data frame conversion and writing into HDFS
- How to solve "Can't assign requested address: Service 'sparkDriver' failed after 16 retries" when running spark code?
- How to flatten an array and convert it into a string?
- Extract variables from string with Regex
- Play WS Recursive Get Requests for Pagination
- How to model Global Constant in Scala using Enum?
- How to invoke default constructor using scala reflection if we have default value defined in our constructor
- Global scope for actions for scala-oauth2-provider with play2 scala
- Random value generator for same variable in json file
- How to read from multiple Elasticsearch indices in Spark?
- Making a while-loop more scala-esqe
- Is it possible to run Spark jobs (like the WordCount sample) in the local mode on Cygwin?
- Non static method in scala Enum
- How to assign a static date to a variable in Scala
- Overriding multiple config values in Typesafe config when using an uberjar to deploy
- Transform String to StringContext to evaluate deferred
- How to inject WSClient in a Play framework project when using Maven?
- Case Classes and Pattern Matching on List
- What's the Akka-typed equivalent to pipeTo?
- error when using fold function in flink
- Retrieving list of objects from application.conf