Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
How to set ID? #21
You can use the property ID from the server if you need to, I think rushorm uses rush_id, so if you want to set the id from server just use the setId(int serverId) and to get it you have to use something like getServerID() because getId returns rush_id. I had that same question when I was doing my app but I had no problem at all using the serverId. That is why I started using RushOrm, i was trying with SugarORM and it was a big conflict because you can not use the property ID, unlike with RushORM.
I'm using @RushList to do the one-to-many, they'll automatically use the rush_id which is private, am I right? This will reflect too, because the "children" are also persisted on the server and they should not carry the rush_id or a fk related to rush_id.
If he could add the setID it would be much much easier to handle, seems pretty straight forward to implement too...
Have you had a look at
It is dependent on your sever giving you your data in json format that matches your java objects, but you can pass in the name of the id field in the json then it will be used in the database instead of creating it's own id. Might be what your looking for.
@Stuart-campbell To create the object with proper ID I must give a JSON to be deserialized? Dont you think its a work around, and those are bad some times? my server already uses its protocol to comunicate with the application, and I really dont want to change that.
If you want, I can do a pull request fixing the setID, making my life, and I bet, many other people life better, ofc, if there isnt a problem with that!
I bet the search children uses the rush_id to go through the children, and thats exactly what I must avoid if I follow the suggestion from @dco5 and create my own ID, since at any time, the local DB can be wiped, and sync'ed again from the server, this will for sure mess things up. It could be better, if I could edit it with setID that could be even easier because all would work without the need of putting extra fields(IDs) and making the one to many relation myself hard coded
No I wouldn't suggest turning into json just to set the id. Was pointing it out as you may have already been deserializing with something like gson so would have been an easy switch.
I think I do understand your use case. Basically you need what the deserialize method does but without using it.
The rush_id is really a "final" property so I think adding a registerObjectWithId method might make more sense than setId.
Although if I add that to RushCore it would be easy for you to add setId to your object that would just call that method.
I should be able to look at that tomorrow.
added a commit
Apr 12, 2015
I have added registerObjectWithId method. So if you call that after creating your objects from your server calling save will create or updated them based on the id you set.