Does Apache OFBiz delegator API support fetching list of records from database by limit or offset

冷暖自知 提交于 2019-12-03 20:59:01

I would you suggest you to take a look into this entity engine cookbook

Essentially for getting limited set of rows from database you would do:

// first get a list iterator
productsELI = delegator.findListIteratorByCondition("Product", 
  new EntityExpr("productId", EntityOperator.NOT_EQUAL, null), 
                  UtilMisc.toList("productId"), null);

// then get a partial list by count TO RETURN first 5 records
productsELI.getPartialList(0, 5);

// and finally just close the iterator
productsELI.close();

Also if you prefer to send direct SQL to your database then just do like this:

// gets the helper (localmysql, localpostgres, etc.) for your entity group org.ofbiz
String helperName = delegator.getGroupHelperName("org.ofbiz");
SQLProcessor sqlproc = new SQLProcessor(helperName);
sqlproc.prepareStatement("SELECT * FROM PARTY LMIT 0, 5");
ResultSet rs1 = sqlproc.executeQuery();

// and then get your data from ResultSet like regular JDBC
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!