Nader Jafari 4 Years Ago Does dynamic query support Entity Cache / Finder Cache? Please sign in to reply. Reply as... Cancel David H Nebinger Nader Jafari 4 Years Ago - Edited Good question, Nader. I don't really know for sure, but my gut tells me it doesn't. I mean, when you're talking about projections and groupings, I think the answer is clearly no because you're not talking about an entity and the group calculations are affected by indirect storage updates (i.e. sum on a column can change if a record is added or modified but falls outside of potential cache lookups). If it is supported, I guess it might only be through a basic query for entities using a restriction; that's about as close to a regular kind of query that you can get that supports a predictable response set, so I could see it possible to cache these results. But honestly I'd want to test before proclaiming there is any caching going on even for those kinds of simple queries. Please sign in to reply. Reply as... Cancel
David H Nebinger Nader Jafari 4 Years Ago - Edited Good question, Nader. I don't really know for sure, but my gut tells me it doesn't. I mean, when you're talking about projections and groupings, I think the answer is clearly no because you're not talking about an entity and the group calculations are affected by indirect storage updates (i.e. sum on a column can change if a record is added or modified but falls outside of potential cache lookups). If it is supported, I guess it might only be through a basic query for entities using a restriction; that's about as close to a regular kind of query that you can get that supports a predictable response set, so I could see it possible to cache these results. But honestly I'd want to test before proclaiming there is any caching going on even for those kinds of simple queries. Please sign in to reply. Reply as... Cancel
Eric D 4 Years Ago Great article David! Do you know if it is possible to do bulk insert too? When we want to import a flat file, the easiest is to do a cancel/replace on all the data of the table. (no logic, no sync problem, no bug) Bulk insert can be great in this case? Please sign in to reply. Reply as... Cancel
Andre Kreienbring 3 Years Ago Shouldn't it be DynamicQuery dq = JournalArticleLocalServiceUtil.dynamicQuery(); at the beginning of the article? I'm having problems to get an instance of *LocalService... Please sign in to reply. Reply as... Cancel David H Nebinger Andre Kreienbring 3 Years Ago Absolutely not. Any of the *LocalServiceUtil classes are for legacy use only, we don't use them any more. To get an instance of JournalArticleLocalService, you just need to @Reference it in on your @Component class and it will be injected. Please sign in to reply. Reply as... Cancel
David H Nebinger Andre Kreienbring 3 Years Ago Absolutely not. Any of the *LocalServiceUtil classes are for legacy use only, we don't use them any more. To get an instance of JournalArticleLocalService, you just need to @Reference it in on your @Component class and it will be injected. Please sign in to reply. Reply as... Cancel
Andre Kreienbring 3 Years Ago Yes, that's true for the Portlet Component. But I've implemented the custom dynamic Query in my [myServicePackage].persistence.impl.[myFinderImpl] class. How do I get my hands on the [myEntitiy]LocalService instance in that situation? I followed this tutorial: https://help.liferay.com/hc/en-us/articles/360030614252-Defining-a-Custom-Finder-Method Please sign in to reply. Reply as... Cancel David H Nebinger Andre Kreienbring 3 Years Ago That page already shows you how to @Reference in a CustomSQL instance, you can use the same @Reference method to inject your *LocalService instance. Please sign in to reply. Reply as... Cancel
David H Nebinger Andre Kreienbring 3 Years Ago That page already shows you how to @Reference in a CustomSQL instance, you can use the same @Reference method to inject your *LocalService instance. Please sign in to reply. Reply as... Cancel
Andre Kreienbring 3 Years Ago I just tried and clearly that was the link I was missing. Thinking about it, it's logical because the Service and API layers ar OSGI components just like the Portlet module! Thank you! :-) Please sign in to reply. Reply as... Cancel
Yahya Allam 2 Years Ago Thank you for this great article. I'm using 7.3.X when trying dq.add(RestrictionsFactoryUtil.in("groupId", groupQuery)); I got error: no suitable method found for in(String,DynamicQuery) dq.add(RestrictionsFactoryUtil.in("groupId", groupQuery)); ^ method RestrictionsFactoryUtil.in(String,Collection<?>) is not applicable (argument mismatch; DynamicQuery cannot be converted to Collection<?>) method RestrictionsFactoryUtil.in(String,Object[]) is not applicable (argument mismatch; DynamicQuery cannot be converted to Object[]) Please sign in to reply. Reply as... Cancel