1

How can we fetch the result of Custom SQL run through Custom finder directly into our POJO class or Wrapper?

As explained in below question:

How to fetch liferay entity through custom-finder in custom plugin portlet?

we can fetch result into liferay entity using below code

// use portal class loader, since this is portal entity
sqlQuery.addEntity("Group_", PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.GroupImpl"));

the same code works for our custom-entity if we write

sqlQuery.addEntity("MyCustomGroup", MyCustomGroupImpl.class);

But we can use custom entity only when we have built it using service builder service.xml build and doing so will create the table for each custom entity in the table.sql file of service builder plugin project.

I don't want to create the separate table for each custom entity. That's the reason I have created java wrapper class and want to inject the result directly into my wrapper class. I don't want to iterate the result set of custom query. Is there any way to do so?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
Varun Chawla
  • 303
  • 1
  • 6
  • 19

0 Answers0