« Back

Hooks revisited (4) - create an entity to hold seach criteria

Create the CustomAssetEntryQuery entity

We want to extend the AssetEntryQuery by adding the String author to the members. This can be done manually with some coding effort. However the use of Service Builder will offer some additional advantages.


<service-builder package-path="...">


<entity name="CustomAssetEntryQuery"

local-service="false" remote-service="false"


<column name="authorName" type="String" primary="true"




The Service Builder creates, among others, the interface CustomAssetEntryQuery, and the class CustomAssetEntryQueryWrapper, with the ubiquitous get and set methods for the authorName. Now we will need to break well-established rules and manually modify the generated class as follows:


public class CustomAssetEntryQueryWrapper

extends AssetEntryQuery

implements CustomAssetEntryQuery,

ModelWrapper<CustomAssetEntryQuery> {

public CustomAssetEntryQueryWrapper(

CustomAssetEntryQuery customAssetEntryQuery) {

super((AssetEntryQuery) customAssetEntryQuery);

_customAssetEntryQuery = customAssetEntryQuery;





Thus we have a class which implements our new custom model interface and also extends the core class AssetEntryQuery, as required in c). Poking around generated code is not nice, of course. It would be way easier if the meta-data had an extensible model. Anyway, the generated class would be overwritten on the next run, so we need to make a backup for further use. Just one thing we should not play with: never rename the generated classes.


In the next segment we will make use of the meta-data extension in a finder. Please read further.