REST api对象检索

I have a very "weird" problem, I guess you can also call it specific.

Here's what I'm trying to do, here's a very simplified version of my db:

+ORDERS
  id
  table_id

+TABLES
  id
  number
  seats

So, let's say I want to fetch my orders from an android Application, I thought of using a JSON to do so (I'm parsing them with retrofit; which uses Gson). Here's how it would look.

{id: '1', table:{id:1, number: 1, seats: 3}}

In my app, I get an object like this

Public Order{

private int id;
private Table table;

}

Great! right?. Well, not quite... the thing is. I don't want to fetch the table every time I fetch the order, because the tables is always the same, it does not change. I want to fetch all tables when the user logs in, save them in a SQLite DB, and then just bring the table ID when fetching the orders (that would reduce the size of my JSON and speed up my queries).

So, this is how my JSON looks now.

{id: '1', table:1}

but now, here how my POJO looks:

Public Order{

private int id;
private int table_id;

}

That's not very "OOP-ish" :/ I cannot do things like myOrder.getTable(). So, that's my predicament. Any idea will be appreciated.

Your first approach is better then second because:

in your first approach:

1.One Http request

if you get table data in json string then it will not cause much impact on performance as your table data is coming as a string in your response.

But in your second approach:

1.One Http request

2.One Sqlite request(Sqlite query will also impact your performance)