Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Dependency issue for JournalArticle Impl in Liferay 7.1
Hi,
I am accessing the journal article impl class for the custom sql i have created.
Below is my piece of code:
SQLQuery query = session.createSQLQuery(sql);
query.setCacheable(false);
query.addEntity("JournalArticle", PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.journal.model.impl.JournalArticleImpl"));
I have below dependencies in build.gradle:
compileOnly group: 'com.liferay', name:
'com.liferay.journal.service', version: '2.0.2'
compileOnly group: "com.liferay.portal", name:
"com.liferay.portal.impl", version: "2.32.0"
compileOnly group: "com.liferay", name:
"com.liferay.journal.api", version: "2.0.0"
compileOnly group: "com.liferay", name:
"com.liferay.journal.web", version: "1.5.0"
But i am getting the below error :
Unresolved requirement: Import-Package: com.liferay.journal.model.impl; version="[1.0.0,2.0.0)"
java.lang.ClassNotFoundException: com.liferay.journal.model.impl.JournalArticleImpl
Not finding any relevant dependency to be added in build.gradle.
Any help would be appreciated.
JournalArticleImpl is not in the portal's class loader. With using PortalClassLoaderUtil.getClassLoader(), you are asking for the portal's class loader which will not have the JournalArticleImpl class in it.
I'm not sure what you're doing, but you may find it a bit easier to just use a dynamic query.
Hi david,
I am trying to get result from multiple table with inner join. So created custom sql for the journal article table.
<custom-sql>
<sql id =
"com.acc.bby.service.persistence.ConfigurationFinder.findJournalArticleByCategoryIds">
SELECT * FROM journalarticle ja
INNER JOIN assetentry
ae ON ae.classPK = ja.resourcePrimKey
INNER JOIN
assetentryassetcategoryrel ae_at ON ae.entryId =
ae_at.assetEntryId
INNER JOIN assetcategory tags ON
ae_at.assetCategoryId = tags.categoryId
WHERE
tags.categoryId IN (?) AND ja.status = (?);
</sql>
</custom-sql>
Attached is my FinderImpl class.
I am facing issue on adding the entity :
query.addEntity("JournalArticle", JournalArticleImpl.class));
I have tried accessing the JournalArticleImpl class using the class loader as well as the above line, but m facing the dependency issues.
Attachments:
I'm not sure there's a workable solution for this.
The different entities are parts of different class loaders. You may not be able to cross these boundaries so easily.
You could select the journalArticle.resourcePrimKey instead and then retrieve the journalArticles yourself via the journalArticleLocalService
Powered by Liferay™