Wednesday, 15 August 2012

java - Saving child collections with OrmLite on Android with objects created from Jackson -


I have a rast service that I am calling from my app, which is a byte in a JSON object turned pulls as the [] then a nested collection of objects - these all work fine fine I be using Ocommait do not want to say, these objects then released SQLite storage, and This is where things start to break, because as I have understood, OrmLite does not continue nested objects automatically. To

For simplicity, let me missed the actual functionality and my objects should be ready just as the:

  @DatabaseTable (tableName = "parent") public Parents of the class {@DatabaseField (id = true) private string name; @forgencollectionfield // is to use the collection here because Jackson should be compatible with the private collection; & Lt; Child & gt; children; / * Gets and senders go here * Database table (table name = "children") Public square hair {@DatabaseField (id = true) Private string name; @DatabaseField (foreign = true) private parents; / * Geters and Sets Go Here * /}   

What happens when a new parent / code in the database with my related parentDao < > Object, children are not maintained with parents.

This is a common question and has been raised before that, certainly there are other questions on the SO which are similar to this one, most notably "Grey" Who would have done manually to create my POJO manually.

However, I have not seen an answer yet, are being produced by another library (Jackson in this case). Jackson Deserialisation Innards (which is without deep excavation deletes the full benefits of its simplicity) and Jackson make the child object and then trying to add parents (unless I'm missing something And does it seem easy?) Which does not seem particularly attractive in this particular case.

Similarly, there are other solutions that add forwarded annotations to the foreign key that seem appropriate to work with a child's items, but @ForeignCollectionField s and Their related archive s. Those annotations are not available when working with

ORMLite-documentation:

"Item Props = "Text">

You can try to use a foreign collection instead of a collection in your original class.

"Alien Collection Aid (support) and remove () objects in the situation in ways that will be connected to the internal L or removed if the collection is curious, and DAO calls [children] to table The class automatically also states that the addition / deletion is sent to the database. To be affected and both curious and lazy collections will also be made. "

()

()

I have never worked with it, however, I hope this document is correct and it helps you to solve your problem. : -)

No comments:

Post a Comment