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: Get all tag of article
How can i get all tags of a journal article using a query on database ? I use Liferay 6.2
Hi Francesco,Are you looking for the SQL statement because you want to run some kind of a report against the data? or do you plan to use the results in the site? If you plan to use it in your site (either through a template, or a custom portlet, etc) then you should go through the API rather than querying the database directly. There are piles of reasons while I say this, and you will find multiple threads in the forum explaining why it is a bad idea. With all that disclaimer stuff out of the way, the table relationships ...
JournalArticle.resourcePrimKey -> AssetEntry.classPKAssetEntry.entryId -> AssetEntries_AssetTags.entryIdAssetEntries_AssetTags.tagId -> AssetTag.tagId
If you write a query joining those columns and tables, you should find what you need. Alternatively, you could just use the Script tab in the Server Administration area of the control panel and leverage the AssetEntryLocalSeviceUtil.getTags(long classNameId, long classPK) method to do that same thing -- classNameId you can lookup in the database our just use the PortalUtil.getClassNameId(JournalArticle.class); to get a hold of it.
JournalArticle.resourcePrimKey -> AssetEntry.classPKAssetEntry.entryId -> AssetEntries_AssetTags.entryIdAssetEntries_AssetTags.tagId -> AssetTag.tagId
If you write a query joining those columns and tables, you should find what you need. Alternatively, you could just use the Script tab in the Server Administration area of the control panel and leverage the AssetEntryLocalSeviceUtil.getTags(long classNameId, long classPK) method to do that same thing -- classNameId you can lookup in the database our just use the PortalUtil.getClassNameId(JournalArticle.class); to get a hold of it.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™