entities - android greendao update only specific fields in entity -
I'm searching for a little while to solve my problem without success.
I have been using GreenDoOutOr-Relay methods in an application I get from different services for a particular unit in my database so that whenever the unit first It is only present in my DB, then it is updated instead of renewal.
So far good.
The problem is ... Let's say, for example, my unit is called with the user, field id, title, and displayplay.
Then in the first call I get a JSON with a user object with its ID and title field only, so I put it in DB and naturally displayName is inserted in the form of a tap.
Later on I get another user (same ID field) from another service, but it also comes with displayName but does not include title information.
So whenever I run on the automatically generated DAO object by Greeniao, the user gets updated, but as the title information was not present, when it is updated, the title field Reset to reset, so I lose data.
Unfortunately I am unable to change the data returned from data, and I have not been able to fix this issue. I find it difficult to understand that the DAO object only updates certain fields There is no easy way to do and not everyone.
I was seeing the code generated by Greene and the Dao object generated from there is a bind value method that is called before executing the query, and apparently ejects the property from the object. , But in some way it gets updated with tap value.
I am being prepared by adding a few ways to the original DAO object, but I do not think this is a good solution because I have to do it for all Dao objects. (I know that it is possible to define a custom superclass, but it only applies to the unit object and not the DAO).
I really appreciate it if someone knows how to solve it, and sorry for long explanations, I just wanted to be clear on my issue .
Thank you.
First of all: I will not tamper with the generated code unless you really know what you do. Amendments may have an effect on the cache and data-integrity.
If you are using ORM-framework (like Grenadro), then you are generally following the (in-dot-or-) -update-approach:
- Try to get the unit, that you want to modify with DB (maybe it's already in the cache, so this can not be a real database operation)
- Modify the unit according to your needs
- Put it in the database or up Date (you will use Insert or Riches in Grethergo)
Comments
Post a Comment