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: How search DLFileEntry/DLFileVersion with specific metadata values?
Hi, I have a text field in my custom type that it is not indexed.
Is it possible to issue a query (Dynamic query) based on that field?
I mean something similar to this (pseudo-)code:
thanks in advance,
Marco
Is it possible to issue a query (Dynamic query) based on that field?
I mean something similar to this (pseudo-)code:
DynamicQuery q=DynamicQueryFactoryUtil.forClass(DLFileVersion.class);
q.add(PropertyFactoryUtil.forName("my-custom-field").like(likeCriteria));
List<dlfileversion> fvList = DLFileVersionLocalServiceUtil.dynamicQuery(q);</dlfileversion>
If not, how can I search for those documents?thanks in advance,
Marco
Hi Marco,
DLFileEntry metadata is not stored in same table, so it is not possible to do that dynamic query.
You can query the search index or you have to query the tables were data is stored.
More information see following links:
DLFileEntry metadata is not stored in same table, so it is not possible to do that dynamic query.
You can query the search index or you have to query the tables were data is stored.
More information see following links:
Jorge DíazHi Marco,
DLFileEntry metadata is not stored in same table, so it is not possible to do that dynamic query.
You can query the search index or you have to query the tables were data is stored.
More information see following links:
Hi Jorge, thank you very much for your suggestions. Unfortunately that field is not indexed so I can't use the the indexer.
Another approach I am trying is to query the ddmcontent.xml column where the metadata are stored, this works fine and I am able to get the ddmContent ids but my second query on DLFileEntryMetadata:
DynamicQuery q=DynamicQueryFactoryUtil.forClass(DLFileEntryMetadata.class);
q.add(PropertyFactoryUtil.forName("ddmstorageid").in(ddmContentsIdsArray));
List<dlfileentrymetadata> fileEntryMetadataList= DLFileEntryMetadataLocalServiceUtil.dynamicQuery(q);</dlfileentrymetadata>
fails raising this exception (??)
org.hibernate.QueryException: could not resolve property: ddmstorageid of: com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl
Do you have any idea why the ddmstorageid property is not found?
My last chance could be process a large bunch of FileVersions and analyze their FieldMaps but I would really prefer to be able to make Database engine do the work for me ;-)
regards,
Marco
Hi Marco,
I think you have some problem with classloaders.
See following link: https://community.liferay.com/forums/-/message_boards/message/98752117#_com_liferay_message_boards_web_portlet_MBPortlet_message_92981243
Try replacing DynamicQueryFactoryUtil.forClass({className}.class) with
For examine, in case of DLFileEntryMetadata, replace DynamicQueryFactoryUtil.forClass(DLFileEntryMetadata.class) with:
More info see:
I think you have some problem with classloaders.
See following link: https://community.liferay.com/forums/-/message_boards/message/98752117#_com_liferay_message_boards_web_portlet_MBPortlet_message_92981243
Try replacing DynamicQueryFactoryUtil.forClass({className}.class) with
{className}LocalServiceUtil.dynamicQuery()
That will avoid classloader issuesFor examine, in case of DLFileEntryMetadata, replace DynamicQueryFactoryUtil.forClass(DLFileEntryMetadata.class) with:
DLFileEntryMetadataLocalServiceUtil.dynamicQuery()
More info see:
Hi Jorge, I did what you suggested me and now my code is:
but the same exception is raised :-(
I did also more investigation and the error occours with any property so I am agree with you that the problem could be something related with class loading but I really can't figure out what difference could be between DDMContent (where the same query run smootly) and DLFileentryMetadata ...
This is really weird...
q=DLFileEntryMetadataLocalServiceUtil.dynamicQuery();
q.add(PropertyFactoryUtil.forName("ddmstorageid").in(ddmContentsIdsArray));
List<dlfileentrymetadata> fileEntryMetadataList= DLFileEntryMetadataLocalServiceUtil.dynamicQuery(q);</dlfileentrymetadata>
but the same exception is raised :-(
I did also more investigation and the error occours with any property so I am agree with you that the problem could be something related with class loading but I really can't figure out what difference could be between DDMContent (where the same query run smootly) and DLFileentryMetadata ...
This is really weird...
Did you tried using camel case in the property name?
I mean to use "ddmStorageId" instead of "ddmstorageid"
I mean to use "ddmStorageId" instead of "ddmstorageid"
No, never tried before...
but same result :-(
SystemException: org.hibernate.QueryException: could not resolve property: ddmStorageId of: com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl
but same result :-(
SystemException: org.hibernate.QueryException: could not resolve property: ddmStorageId of: com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl
Hi Marco,
com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl extends com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataModelImpl
I have checked that class and it seems property is called DDMStorageId, with DDM in uppercase, see:
Can you try using that property name?
I hope that solves your problem, as I am running out of ideas.
In case that doesn't solve your issue, can you attach your whole log file with the error?
Regards,
Jorge Díaz
com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl extends com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataModelImpl
I have checked that class and it seems property is called DDMStorageId, with DDM in uppercase, see:
Can you try using that property name?
I hope that solves your problem, as I am running out of ideas.
In case that doesn't solve your issue, can you attach your whole log file with the error?
Regards,
Jorge Díaz
Jorge DíazHi Marco,Jorge, with DDMStorageId it works!!
com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataImpl extends com.liferay.portlet.documentlibrary.model.impl.DLFileEntryMetadataModelImpl
I have checked that class and it seems property is called DDMStorageId, with DDM in uppercase, see:
Can you try using that property name?
I hope that solves your problem, as I am running out of ideas.
In case that doesn't solve your issue, can you attach your whole log file with the error?
Regards,
Jorge Díaz
I think this should be definly better documented, but thank you very much for all your support!
regards,
Marco
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™