java - GSON to Ormlite foreign collection -


My model object contains simple datatype as well as other types of model objects

  @ SerializedName ("account") account account; ` 

I serialize these model objects from a network API call using GSON . GSON needs its model objects, their respective type, I want to write my model objects in the database using the ombileite and batch functions, but Ormlite should be ForeignCollection & lt; T & gt; is required, even if I have only one foreign object (instead of the list of foreign objects) model.

I use ForeignCollection & lt; from a serial element of T in my model file. T & gt; How do I get it?

The real question of the curriculum is to serial and store models in my database, which includes references to other models.

It is not very clear what you are asking here, but it may be useful

  Specify spacesAllegayConcolution (T parent, string fieldname) throws SQLException  

creates an empty archive And specifies it on the appropriate field in the original object, it lets you add things to the collection from the beginning. For example, suppose you have an account in which the field is:

  @ForeignCollectionField (columnName = "command") collection & lt; Order & gt; order;  

You will then call: (in this case)

  accoundDao.assignEmptyForeignCollection (account, "order"); Order 1 Order 1 = New GSON (). FromJson (Some Mathuthatus Your Network API), Order. Class); // This will add archiving and internal DAO accounts .orders.add (order1);  

Comments