the
pojo facade is to simplify working with custom pojos.
PojoQueryBuilder keeps all the powerful queries available via
StructuredQueryBuilder while enabling queries across objects
persisted using PojoRepository.
For methods which accept a "pojoProperty" argument we are refering to properties appropriate for JavaBeans, including properties accessible via public getters and setters, or public fields.
Where StructuredQueryBuilder accepts
StructuredQueryBuilder.TextIndex as a first argument to
value(TextIndex, String...) and
word(TextIndex, String...) methods,
PojoQueryBuilder adds shortcut methods which accept as the first
argument a String name of the pojoProperty. Similarly,
PojoQueryBuilder accepts String pojoProperty arguments wherever
StructuredQueryBuilder accepts StructuredQueryBuilder.Element,
StructuredQueryBuilder.Attribute, and
StructuredQueryBuilder.PathIndex as arguments to
geoAttributePair(Element, Attribute, Attribute),
geoElement(Element),
geoElement(Element, Element),
geoElementPair(Element, Element, Element),
geoPath(PathIndex)
Here are a couple examples. Without the pojo facade you might
persist your products using JacksonDatabindHandle
and query the json property thusly:
StructuredQueryBuilder sqb = new StructuredQueryBuilder();
QueryDefinition query = sqb.value(sqb.jsonProperty("productId"), 12345);
If you use PojoRepository
to persist your products, you can query more simply:
PojoQueryBuilder pqb = pojoRepository.getQueryBuilder();
QueryDefinition query = pqb.value("productId", 12345);
Similarly, without the pojo facade you might persist your pojos
using JAXBHandle and
if they have a geoPosition property which is an object with
latitude and longitude pojoProperty's (which persist as elements)
you might query them thusly:
StructuredQueryBuilder sqb = new StructuredQueryBuilder();
StructuredQueryBuilder.GeospatialIndex geoIdx = sqb.geoElementPair(
sqb.element("geoPosition"), sqb.element("latitude"), sqb.element("longitude"));
But if you use PojoRepository
to persist your pojos with a latitude and longitude pojoProperty's,
you can query them more simply:
PojoQueryBuilder pqb = pojoRepository.getQueryBuilder();
StructuredQueryBuilder.GeospatialIndex geoIdx =
pqb.geoPair("latitude", "longitude");
As custom pojos may have nested pojos, PojoQueryBuilder also makes it easy to query those nested pojos. For example, if you had the following classes:
class City {
@Id int id;
Country country;
int getId();
void setId(int id);
Country getCountry();
void setCountry(Country country);
}
class Country {
String continent;
String getContinent();
void setContinent();
}
That is, you have a pojo class City with a property "country" of type Country, you could query properties on the nested country thusly:
PojoRepository<City, Integer> cities =
databaseClient.newPojoRepository(City.class, Integer.class);
PojoQueryBuilder<City> citiesQb = cities.getQueryBuilder();
PojoQueryBuilder<Country> countriesQb = citiesQb.containerQueryBuilder("country", Country.class);
QueryDefinition query = countriesQb.value("continent", "EU");
static
enum StructuredQueryBuilder.Operator.and (StructuredQueryDefinition... queries)StructuredQuerybuilder.and.andNot (StructuredQueryDefinition positive,
StructuredQueryDefinition negative)StructuredQuerybuilder.andNot.boost (StructuredQueryDefinition matchingQuery,
StructuredQueryDefinition boostingQuery)StructuredQuerybuilder.boost.box (double south,
double west, double north, double east)StructuredQuerybuilder.box.build (StructuredQueryDefinition... queries)StructuredQuerybuilder.build.circle (double latitude,
double longitude, double radius)StructuredQuerybuilder.circle(double, double,
double).circle (StructuredQueryBuilder.Point center,
double radius)StructuredQuerybuilder.circle(StructuredQueryBuilder.Point,
double).collection (String... uris)StructuredQuerybuilder.collection(String...).containerQuery (String pojoProperty, StructuredQueryDefinition query)<C> PojoQueryBuilder<C>containerQueryBuilder (String pojoProperty, Class<C> clazz)geospatial query, reference a pair of
properties.geospatial query, reference a geo property which
has a corresponding Geospatial Path Range Index configured in the
database.geospatial (StructuredQueryBuilder.GeospatialIndex index,
StructuredQueryBuilder.Region... regions)geospatial (StructuredQueryBuilder.GeospatialIndex index,
String[] options, StructuredQueryBuilder.Region... regions)StructuredQuerybuilder.geospatial(StructuredQueryBuilder.GeospatialIndex,
StructuredQueryBuilder.FragmentScope, String[],
StructuredQueryBuilder.Region...) but without
StructuredQueryBuilder.FragmentScope.near (int distance,
double weight, StructuredQueryBuilder.Ordering order,
StructuredQueryDefinition... queries)near (StructuredQueryDefinition... queries)StructuredQuerybuilder.near(StructuredQueryDefinition...).not (StructuredQueryDefinition query)StructuredQuerybuilder.not.notIn (StructuredQueryDefinition positive,
StructuredQueryDefinition negative)StructuredQuerybuilder.and.or (StructuredQueryDefinition... queries)StructuredQuerybuilder.and.point (double latitude,
double longitude)StructuredQuerybuilder.point.polygon (StructuredQueryBuilder.Point... points)StructuredQuerybuilder.polygon.range (String pojoProperty, PojoQueryBuilder.Operator operator,
Object... values)range (String pojoProperty, String[] options, PojoQueryBuilder.Operator operator,
Object... values)StructuredQuerybuilder.term(double,
String...).
StructuredQuerybuilder.term(String...).pojoProperty - the property container to match
againstquery - the query to match within the
containerC - the type of the class contained by
pojoPropertypojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class T that is a pojo
of type clazzclazz - the class type of the nested pojogeospatial query, reference a pair of properties.
These properties should ideally have Geospatial Element Pair
Indexes configured in the database. For help creating these
indexes, see GenerateIndexConfig,
GeospatialLatitude, and
GeospatialLongitude.latitudePropertyName - the name of a field or
JavaBean property (accessed via getter or setter) ideally annotated
with @GeospatialLatitudelongitudePropertyName - the name of a field or
JavaBean property (accessed via getter or setter) ideally annotated
with @GeospatialLongitudegeospatial query, reference a geo property which
has a corresponding Geospatial Path Range Index configured in the
database. For help creating this index, see GenerateIndexConfig
and
GeospatialPathIndexProperty.pojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class T ideally
annotated with @GeospatialPathIndexPropertydatatype
configured. For help creating this index, see GenerateIndexConfig
and
PathIndexProperty.pojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class T annotated with
@PathIndexPropertyoperator - the operator used to compare property
values with passed valuesvalues - the possible datatyped values for the
comparison. Make sure the datatypes match the datatype
configured.datatype
configured. For help creating this index, see GenerateIndexConfig
and
PathIndexProperty.pojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class T annotated with
@PathIndexPropertyoptions - options
for fine tuning the queryoperator - the operator used to compare property
values with passed valuesvalues - the possible datatyped values for the
comparison. Make sure the datatypes match the datatype
configured.pojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Tvalues - match a persisted pojo of type T if it
has the property with any of the valuespojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Tvalue - match a persisted pojo of type T if it has
the property with the boolean valuepojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Tvalues - match a persisted pojo of type T if it
has the property with any of the numeric valuespojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Toptions - options
for fine tuning the queryweight - the multiplier for the match in the
document rankingvalues - match a persisted pojo of type T if it
has the property with any of the valuespojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Toptions - options
for fine tuning the queryweight - the multiplier for the match in the
document rankingvalue - match a persisted pojo of type T if it has
the property with the boolean valuepojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Toptions - options
for fine tuning the queryweight - the multiplier for the match in the
document rankingvalues - match a persisted pojo of type T if it
has the property with any of the numeric valuespojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Twords - match a persisted pojo of type T if it has
the property with any of the words or phrasespojoProperty - the name of a field or JavaBean
property (accessed via getter or setter) on class Toptions - options for
fine tuning the queryweight - the multiplier for the match in the
document rankingwords - match a persisted pojo of type T if it has
the property with any of the words or phrasesStructuredQuerybuilder.and. Defines an AND query
over the list of query definitions.queries - the query definitionsStructuredQuerybuilder.andNot. Defines an AND NOT
query combining a positive and negative query. You can use an AND
or OR query over a list of query definitions as the positive or
negative query.positive - the positive query definitionnegative - the negative query definitionStructuredQuerybuilder.boost. Defines a boost
query for the matching and boosting query definitions. The matching
or boosting query definitions can each be an AND or OR query
definition for complex combinations of criteria.matchingQuery - the query definition that filters
documentsboostingQuery - the query definition that
increases the rank for some filtered documentsStructuredQuerybuilder.box. Specifies a geospatial
region as a box, supplying the coordinates for the perimeter.south - the latitude of the south coordinatewest - the longitude of the west coordinatenorth - the latitude of the north coordinateeast - the longitude of the east coordinateStructuredQuerybuilder.build. Builds a structured
query in XML from the list of query definitions. The structured
query can be passed to the search() method of QueryManager.queries - the query definitionsStructuredQuerybuilder.circle(double, double,
double). Specifies a geospatial region as a circle,
supplying coordinates for the center.latitude - the latitude coordinate of the
centerlongitude - the longitude coordinate of the
centerradius - the radius of the circleStructuredQuerybuilder.circle(StructuredQueryBuilder.Point,
double). Specifies a geospatial region as a circle,
supplying a point for the center.center - the point defining the centerradius - the radius of the circleStructuredQuerybuilder.collection(String...).
Matches documents belonging to at least one of the criteria
collections.uris - the identifiers for the criteria
collectionsStructuredQuerybuilder.geospatial(StructuredQueryBuilder.GeospatialIndex,
StructuredQueryBuilder.FragmentScope, String[],
StructuredQueryBuilder.Region...) but without
StructuredQueryBuilder.FragmentScope. Matches an element, element
pair, element attribute, pair, or path specifying a geospatial
point that appears within one of the criteria regions.index - the container for the coordinates of the
geospatial pointoptions - options for fine tuning the queryregions - the possible regions containing the
pointStructuredQuerybuilder.geospatial(StructuredQueryBuilder.GeospatialIndex,
StructuredQueryBuilder.Region...). Matches an element,
element pair, element attribute, pair, or path specifying a
geospatial point that appears within one of the criteria
regions.index - the container for the coordinates of the
geospatial pointregions - the possible regions containing the
pointStructuredQuerybuilder.near(int, double,
StructuredQueryBuilder.Ordering,
StructuredQueryDefinition...). Defines a NEAR query over
the list of query definitions with specified parameters.distance - the proximity for the query termsweight - the weight for the queryorder - the ordering for the query termsqueries - the query definitionsStructuredQuerybuilder.near(StructuredQueryDefinition...).
Defines a NEAR query over the list of query definitions with
default parameters.queries - the query definitionsStructuredQuerybuilder.not. Defines a NOT query
for a query definition. To negate a list of query definitions,
define an AND or OR query over the list and define the NOT query
over the AND or OR query.query - the query definitionStructuredQuerybuilder.and. Defines a not-in query
for the positive and negative query definitions. These query
definitions can each be an AND or OR query definition for complex
combinations of criteria.positive - the query definition that includes
documentsnegative - the query definition that excludes
documentsStructuredQuerybuilder.and. Defines an OR query
over the list of query definitions.queries - the query definitionsStructuredQuerybuilder.point.
Specifies a geospatial point.latitude - the latitude coordinatelongitude - the longitude coordinateStructuredQuerybuilder.polygon. Specifies a
geospatial region as an arbitrary polygon.points - the list of points defining the perimeter
of the regionStructuredQuerybuilder.term(double, String...).
Matches documents containing the specified terms, modifying the
contribution of the match to the score with the weight.weight - the multiplier for the match in the
document rankingterms - the possible terms to match
StructuredQuerybuilder.term(String...). Matches
documents containing the specified terms.terms - the possible terms to matchquery - the query to mark as filteredCopyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.