Message Boards

How to build a query to join content id and template and structure

Alonso Hernandez, modified 5 Years ago.

How to build a query to join content id and template and structure

New Member Posts: 7 Join Date: 11/17/15 Recent Posts
Not sure, if this is the right forum to post this question.
I'm new to Liferay 7 and I'm trying to figure out the data base scheme.

I want to pull a query that join web content id, template name, structure name.

How can i do that?

And if you have any advice for me to learn the DB scheme other than diving in and cracking up queries, i would be more that grateful. Thanks!
thumbnail
Christoph Rabel, modified 5 Years ago.

RE: How to build a query to join content id and template and structure

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
General advice: You should try to avoid to rely on any relationship in the database. The database is messy, not build according to current best practice and subject to change.

You can easily find all these information through the API.
With the articleId you can use JournalArticleLocalService.getArticle to fetch the article.
https://docs.liferay.com/ce/apps/web-experience/latest/javadocs/com/liferay/journal/service/JournalArticleLocalService.html

The JournalArticle has two methods: getDDMStructure() and getDDMTemplate() that give you the structure and the template.

You can be sure, that this API is stable and will always work as intented.


If you really, really want to do this through the database, the JournalArticle table contains the structureId and the templateId. A join to the ddm tables should be sufficient to give you the data you need. But please take care, this might change with any Liferay patch. It might lot be likely, but it could change.