I have two entities: "Orders" and "WorkPosition". The Workpositions are related through the id of the orders, that means i have an toMany-Relationship here. One order have "n" Workpositions and one Workpostion has always an order_id. So there is a function: order.getWorkPositions().
What i am doing right now:
Rightnow i am querying all Orders and then i am iterating through the Orders. If an order has workpositions that have workposition.type="1".
The problem is that this is very slow, because i have at least 1000 orders and even more workpositions.
Question:
I saw that the "join" function is not working, but on the greenDao Homepage i saw the following Query:
Query query = userDao.queryBuilder().where(
new StringCondition("_ID IN " +
"(SELECT USER_ID FROM USER_MESSAGE WHERE READ_FLAG = 0)").build();
How can i use it to speedup my query? Can i have orders as a returntype from the query? Or can i have only a list of ids?
As a query i want something like this:
Query<Orders> query = getDAOSession().getOrdersDao().queryBuilder()
.where(new StringCondition("?_ID IN? "+
"(SELECT * FROM Orders AS O JOIN WorkPosition AS W WHERE w.type=1)")).build();
List<Orders> orders = query.list();
I hope you can understand my question, if not tell me and i will try to improve it!:)