Examples

Even with all of the above, there are a few cases that stand out with possibly needing examples in order to help. Notably, dealing with language entries and lookups may be confusing.

Here is an example of selecting all algorithm types where the description is like some input:


String likeDescription = ...;
Query query = createQuery("from AlgorithmType_Language algTypeLang join algTypeLang.id.parent algType where algTypeLang.description like :likeDescription and algTypeLang.id.language = :language");
query.bindEntity("language", getActiveContextLanguage());
query.addResult("algType", "algType);
query.bindLikableStringProperty("likeDescription", AlgorithmType.properties.languageDescription, likeDescription);
List algorithmTypes = query.list();

The algorithmTypes list will contain as elements the algorithm types whose description is like likeDescription. Note that the string likeDescription will have a trailing '%' appended when it is bound to the query.

Here is an example of selecting particular lookup values, with descriptions like an input value:


        String description = header.getString(STRUCTURE.HEADER.DESCR);
        Query query = createQuery("from LookupValue_Language lookupValLang "
                 + "where upper(lookupValLang.description) like upper(:description) and lookupValLang.id.language = :language and "
                 + "lookupValLang.id.parent.id.fieldName = 'RPT_OPT_FLG');
        query.bindLikableStringProperty("description", LookupValue.properties.languageDescription, description);
        query.bindEntity("language", getActiveContextLanguage());
        query.addResult("lookupValue", "lookupValLang.id.parent");
        query.addResult("description", "lookupValLang.description");
        query.orderBy("description");
        List results = query.list();

The list results will contain QueryResultRows, with values keyed by "lookupValue" and "description".