@@ -5,7 +5,7 @@ import app.softnetwork.persistence._
55import app .softnetwork .persistence .jdbc .db .SlickDatabase
66import app .softnetwork .persistence .model .{StateWrapper , Timestamped }
77import app .softnetwork .persistence .query .JsonProvider
8- import app .softnetwork .serialization .{ serialization , updateCaseClass }
8+ import app .softnetwork .serialization .serialization
99import org .json4s .Formats
1010import slick .jdbc .JdbcProfile
1111
@@ -40,6 +40,8 @@ trait JdbcStateProvider[T <: Timestamped]
4040 case _ => table
4141 }
4242
43+ def excludedFields : Set [String ] = Set (" __serializedSizeMemoized" )
44+
4345 implicit def executionContext : ExecutionContext
4446
4547 import api ._
@@ -107,11 +109,19 @@ trait JdbcStateProvider[T <: Timestamped]
107109 * @return
108110 * whether the operation is successful or not
109111 */
110- override final def upsertDocument (uuid : String , data : String ): Boolean = {
112+ override def upsertDocument (uuid : String , data : String ): Boolean = {
111113 (loadDocument(uuid) match {
112114 case Some (document : T ) =>
113115 implicit val manifest : Manifest [T ] = manifestWrapper.wrapped
114- Try (updateCaseClass(document, serialization.read[Map [String , Any ]](data))) match {
116+ var state = serialization.read[Map [String , Any ]](serialization.write(document))
117+ val updatedState = serialization.read[Map [String , Any ]](data)
118+ for ((key, value) <- updatedState) {
119+ if (! excludedFields.contains(key)) {
120+ state = state + (key -> value)
121+ }
122+ }
123+ val updatedDocument = serialization.write(state)
124+ Try (serialization.read[T ](updatedDocument)(formats, manifest)) match {
115125 case Success (updatedState : T ) =>
116126 Some (updatedState)
117127 case Failure (e) =>
0 commit comments