Questions tagged [salat]

Salat is a bi-directional Scala case class serialization library that leverages MongoDB's `DBObject` (which uses BSON underneath) as its target format.

The Salat project focuses on speed and simplicity of serializing case classes to and from target formats.

Salat is not a fully-fledged ORM and does not attempt to match the flexibility, compability or functionality of an ORM that would let you define relationships between classes, provide a query language, or serialize/deserialize every collection type known to Java or Scala.

109 questions
1
vote
1 answer

Create implicit json read for List collection which might be missing from input json

I am following play-salat (github.com/leon/play-salat) to create a model for a json input and save to mongodb. How can I create the implicit json read for List collection which might be missing in the input json? The following code gives me the…
angelokh
  • 9,426
  • 9
  • 69
  • 139
1
vote
1 answer

Using Composite Keys with Salat and MongoDB

I've just read this post on how to use composite keys with Salat and MongoDB... and it is more or less clear how it works. Nevertheless, I'm wondering if the @Key annotation is mandatory even if my key is already named id. I'm trying to serialize a…
j3d
  • 9,492
  • 22
  • 88
  • 172
1
vote
2 answers

How to accumulate errors in a functional way upon validating database object?

I have Product case class, which is returned by DAO layer (using Salat). User who is creating a product first time status of the product remains as "draft" where no field (of product) is mandatory. What are the best functional ways to validate 10…
user2066049
  • 1,371
  • 1
  • 12
  • 26
1
vote
1 answer

Multiple documents update mongodb casbah scala

I have two MongoDB collections promo collection: { "_id" : ObjectId("5115bedc195dcf55d8740f1e"), "curr" : "USD", "desc" : "durable bags.", "endDt" : "2012-08-29T16:04:34-04:00", origPrice" : 1050.99, "qtTotal" : 50, …
user2066049
  • 1,371
  • 1
  • 12
  • 26
1
vote
2 answers

Using ModelCompanion's fromJSON method in Play application throws a NoSuchMethodException

I'm new to Scala and I'm trying to do my first Play 2.0 application. I'm using: Scala 2.9.3 Play 2.0.4 SalatWithPlay2 1.1 I have this in my conf/routes file: PUT /newVenue controllers.Application.createNewVenue I have this in my…
Carla
  • 205
  • 3
  • 10
1
vote
1 answer

Enumerations -> Sealed trait with a "Value"?

This question is related to the first one: Iteration over a sealed trait in Scala? I have the following sealed trait /** * @author Sebastien Lorber (lorber.sebastien@gmail.com) * Date: 02/12/12 - Time: 17:49 */ sealed trait ResizedImageKey…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
1
vote
3 answers

How to update object in Mongo with an immutable Salat case class

I'm working on a project with Scala, Salat, Casbah, Mongo, Play2, BackboneJS... But it's quite a lot of new things to learn in the same time... I'm ok with Scala but I find my code crappy and I don't really know what's the solution to improve…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
1
vote
1 answer

Pre-persistence validation for Scala case class using Salat/Casbah

Assuming that I have a Scala case class that is persisted using the Salat/Casbah/Mongo stack, I want to set up pre-persistence validation logic like I could easily do in Rails using ActiveRecord hooks or in Java using JSR 303 bean…
kgx
  • 1,195
  • 3
  • 15
  • 26
1
vote
2 answers

Can I manage the scope of Salat case class DTOs by using a companion Object?

I've been using Salat within a Play2 webapp for MongoDB interaction (via Leon Radley's neat SBT plugin). Works great, however as we have many case class DTOs due to nesting (to mirror nested JSON/BSON model definitions) we wanted to neatly define…
DaveE
  • 11
  • 1
0
votes
2 answers

How to update/delete an embedded object

Given following domain model: case class Benefits(id: Int, benefitPlan: String, comment : String) case class Employee(empNum : Int, benefits : List[Benefit]) I've been using Salat to help derialize/deserialize these objects. However, I'm a little…
cracked_all
  • 1,331
  • 1
  • 11
  • 26
0
votes
1 answer

Salat - Why it creating two id fields

What I tried: I tried around one and half day, not resolved yet. I tried by creating MyEntityTemp entity similar to MyEntity and written a converter. Even I am getting two id fields. Please need help to resolve. I found some of MyEntity inherited…
Sri Manga
  • 561
  • 1
  • 5
  • 8
0
votes
1 answer

NullPointerException in Salat

While making any type of call to Mongo from my Scala application, I am getting this NullPointerException. Can somebody please help. I am using Mongo 3.0.1 and my Scala version is 2.9.0. Other dependencies are as follows
RckR
  • 45
  • 4
0
votes
0 answers

uri has type STRING rather than OBJECT in Scala and MongoDB integration?

I am working with Play framework(2.2.x) using Scala and MongoDB(v 2.6.11). I am trying to run sample application using in my system, as it is not executing the application and giving the compilation error in application.conf: uri has type STRING…
Nag
  • 129
  • 2
  • 3
  • 10
0
votes
1 answer

Read data from mongo DB using scala for list of case classes

I am new to mongoDB and scala, I have created case clase like case class ABC(value1:String, Value2:String, Value3:Int) and case class ListOfABC(listofABC: List[ABC]) I have created implicit formater for json to string and vice versa for both…
Sanjay Rabari
  • 2,091
  • 1
  • 17
  • 32
0
votes
1 answer

How to encapsulate SalatMongoCurser in Salat DAO?

Here a solution is explained on how to encapsulate database specific MongoDBObject when making a call to a salat DAO method. Now if I use the find method that returns a SalatMongoCursor, my code will again be dependent on the specific database. I…
Mahdi
  • 1,778
  • 1
  • 21
  • 35