Message Boards

Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Pankaj Kumar, modified 4 Years ago.

Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Hi All,I am using Liferay DXP 7.2.While calling custom sql i am getting below error 
Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL, but class was expected

I am using @Reference
    private CustomSQL _customSQL;

to read the custom sql file.
Can any body help me on this.
thumbnail
Christoph Rabel, modified 4 Years ago.

RE: Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
You need CustomSQLUtil.
Add the following to your gradle dependencies. Then you should be able to use it in your code.
compileOnly 'com.liferay:com.liferay.portal.dao.orm.custom.sql:1.0.0'
Pankaj Kumar, modified 4 Years ago.

RE: Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
Hi Chris,
I tried that option getting below error.
java.lang.NoClassDefFoundError: Lcom/liferay/portal/dao/orm/custom/sql/CustomSQLUtil;
thumbnail
krishna patel, modified 4 Years ago.

RE: Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

New Member Posts: 14 Join Date: 5/21/18 Recent Posts
Hi pankaj,
Have you tried compileInclude to add dependency at runtime?
compileInclude group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.3'

You can also include or exclude the transitive dependencies by,
​​​​​​​compileInclude group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.3', transitive:false
thumbnail
Olaf Kock, modified 4 Years ago.

RE: Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
krishna patel:

Hi pankaj,
Have you tried compileInclude to add dependency at runtime?
compileInclude group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.3'

You can also include or exclude the transitive dependencies by,
​​​​​​​compileInclude group: 'com.liferay', name: 'com.liferay.portal.dao.orm.custom.sql', version: '1.0.3', transitive:false
Nope, do not just try compileInclude randomly, and especially not on Liferay-delivered dependencies.
Coming back to the original post: @Reference provides a reference to a service - in order to use CustomSQL, I'd expect that you'll have to use an additional filter to determine which customSQL you'd like - that is provided that customSQL is registered as service at all.
I currently have no code available to check, but with a pure reference and no filter, this is definitely not what you expect.
Pankaj Kumar, modified 4 Years ago.

RE: Found interface com.liferay.portal.dao.orm.custom.sql.CustomSQL

Regular Member Posts: 101 Join Date: 7/27/14 Recent Posts
I used com.liferay.portal.dao.orm.custom.sql.api dependence  and its start working.