scala - Visibility between two writers -


I get an error when writing authors for these two models.

These are my models:

  Case category ad (var id: long, var account: account, ... var Image: list [pictures]) Model object advertisement Provides {inserted adWrites = Json.writes [Ad]} case class picture (var id: long, var ad: ad) enhances the model object picture {Institue Pixel = Jason.Lits [Picture] Built-in DF CatalogPicture [PicturesCal ] (Built-in FMT: LTTE [picturecards]): written [list ]] = New typed [catalog [Pictures]] {DR (List: List [Picturecards]] writes = JSRere (TMP (T = & gt; JSON TCSON (T) (FMT))}} < / Code>  

This does not work, I get the following message: On the image (=> No built-in writing for model. Edsalka is available.) And on adWrites (= & gt; ; "No built-in writing is available for Java.util.List [models.PictureScala].").

I think this is because each authors need a method of writing the second case class. But how can I solve this problem? If I comment on "ad" and "image" var then it works fine.

Jason writes. Macro is not working in this case Because your types are recursive. Obviously defining your write examples is not very bad, though:

  import play.api.libs.functional.syntax._ import play.api .libs.json ._ // For the complete work example, the next two rows attribute model type account = string case class ad (var id: long, var account: account, white picture: list [pictures]) enhances model object ed {Intex Val adwits: written [ed] = ((__ \ 'id) written [long] and (__ \' account). Write [account] and (__ 'Picture).' [List] [Picture]] (Unlift (ed. Unplay)) Case Category Image (var ID: Long, Var Advertising: Advertising) Enhances Model Object Picture {Entwistle Valley Picture: Article: [Picture] = ((__ \ 'id) .write [long] and (__' ad) .lazyWrite (Ad.adWrites)) (unlift (picture .apply))}   

And then:

  scala> Val ad1 = Ad (1, "foo", zero) Advertisement 1: Advertising = Advertisement (1, Foo, list ()) Scale & gt; Val adee 2 = ed (2, "bar", list (picture (1, ed1) ad 2: advertisement = advertisement (2, time, list (image (1, advertisement (1, af, list ()) ); Scala & gt; ("id": 1, "Advertisement": {"id": json.pretty print (json.tojson (ad2)) res8: string = {"id": 2, "account": " Bar "," picture ": 1," account ":" foo "," picture ": []}}]}   

especially lazy writer In picture diagram , which is required due to recursive.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -