java - How to speed up eager loading of foreign collections? -


i have database table mapped ormlite, contains data (18 columns) , contains foreigncollectionfield(eager = true).

problem when loading data table ... ormlite creating query every item instead using joins. resulting in 67124 queries , taking forever load objects table.

this done in right join query under few seconds? why generate thousands of queries instead?

how can speed up? have write raw query , rawrowmapper , makes using orm pointless..

how deal loading eager collections in ormlite? because queryforall not way..

problem when loading data table ... ormlite creating query every item instead using joins. resulting in 67124 queries , taking forever load objects table.

it's orm_lite_ reason. lot of people have asked join support on foreign collections i've not gotten yet. it's not easy.

if still want use ormlite i'd recommend not using eager = true , doing 2 queries instead. 1 query main item , query using dao associated collection entity using in. like:

qb = accountdao.querybuilder(); qb.where()...; list<account> accounts = qb.query();  // build list of account-ids list<long> accountids = new arraylist<>(); (account account : accounts) {     accountids.add(account.getid()); }  // use list of ids other entities list<order> orders = orderdao.querybuilder().where().in("accountid", accountids).query(); // have list of orders of ids // need associate each order account 

hope helps.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -