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: Custom SQL-Query
Hey Liferay-Community,
So I finally got multiple React-Portlets up and running and they all get their data via REST from my REST-module.
In one React-Portlet I am using the configuration.json to set values in the configuration_-Table (dictionary-Column).
Is there a simple way how I can access this entry now?
Like: SELECT dictionary FROM configuration_ WHERE configurationId = 'NAME-OF-MY-PORTLET'
I stumbled over dynamicQueries but I have no clue how to adapt it to Liferay-Tables?
I just need a simple way to get some configuration-Settings (for example colorCode or title of the section) to my REST-Module.
So I finally got multiple React-Portlets up and running and they all get their data via REST from my REST-module.
In one React-Portlet I am using the configuration.json to set values in the configuration_-Table (dictionary-Column).
Is there a simple way how I can access this entry now?
Like: SELECT dictionary FROM configuration_ WHERE configurationId = 'NAME-OF-MY-PORTLET'
I stumbled over dynamicQueries but I have no clue how to adapt it to Liferay-Tables?
DynamicQuery guestbookQuery = DynamicQueryFactoryUtil.forClass(Guestbook.class, classLoader)) .add(RestrictionsFactoryUtil.eq("name", guestbookName)) .setProjection(ProjectionFactoryUtil.property("guestbookId"));
I just need a simple way to get some configuration-Settings (for example colorCode or title of the section) to my REST-Module.
Solution for me that worked - but is absolutely not they way that I prefer:
Class.forName("com.mysql.cj.jdbc.Driver") ;
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/.......) ;
Statement stmt = conn.createStatement() ;
String query = "select dictionary from configuration_ where configurationId='PORTLET-NAME';" ;
ResultSet rs = stmt.executeQuery(query) ;
while ( rs.next() ) {
String configurationSettings = rs.getString("dictionary");
System.out.println(configurationSettings);
}
If you have at least something related to service builder you could make use of the custom-sql functionality (as described here: https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL)
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™