Legacy Knowledge Base
Published Jun. 30, 2025

AssetEntryQuery returns empty results for the className User

Written By

Peter Schwarcz

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • We found that AssetEntryQuery always returns an empty result when the className is set to "User". Is this an intended behavior?
  • In order to replicate, change "xxxxx" to a valid userId and run the following groovy script. Note the userAssetEntry value will be set but the userAssetEntries will be an empty list.
import com.liferay.asset.kernel.service.AssetEntryLocalServiceUtil
import com.liferay.asset.kernel.service.persistence.AssetEntryQuery
import com.liferay.portal.kernel.model.User
import com.liferay.portal.kernel.service.UserLocalServiceUtil
userId = xxxxx
user = UserLocalServiceUtil.getUser(userId)
userAssetEntry = AssetEntryLocalServiceUtil.getEntry(User.class.getCanonicalName(), user.getPrimaryKey())
AssetEntryQuery assetEntryQuery = new AssetEntryQuery()
assetEntryQuery.setClassName(User.class.getCanonicalName())
userAssetEntries = AssetEntryLocalServiceUtil.getEntries(assetEntryQuery)

out.println("userAssetEntry: " +  userAssetEntry)
out.println("userAssetEntries: " +  userAssetEntries)

Environment

  • DXP 7.3

Resolution

  •  User Assets are by default not visible, so if you wish to query them through AssetEntryQuery, you'd need to add assetEntryQuery.setVisible(false) to the script before executing the AssetEntryLocalServiceUtil.getEntries. Adding this should result in userAssetEntries no longer being an empty list.
Did this article resolve your issue ?

Legacy Knowledge Base