Queries and backward-chaining
Queries were introduced in Chapter 5, Understanding KIE Sessions, as a way to retrieve information from a KIE Session. But queries are much more powerful than that in Drools. As a matter of fact, queries are the way Drools implements what is called backward-chaining reasoning. But before entering this new topic, and given that we were already talking about PHREAK, let's see how a regular query looks in the PHREAK network.
For this section of the book, we are going to introduce a new Java class that will be used to establish a whole-part relationship between Item
objects. What this means it that an Item
can now be composed of other Items
:
The whole-part relationship between Items
is modeled as a generic class, called IsPartOf
. This generic class allows us to define non-intrusive relationships, not just between Items
, but also between any other types of object in our model. As an example, if we want to specify the relation between a car
, an engine
, and a distributor...