Drools将变量变为意外变量

时间:2017-09-08 13:55:58

标签: drools

我不会从查询公司对象返回。但IDE将公司称为意外

enter image description here

我的错误是什么:

dialect  "java"

query getBalance(World world, Company company)
    $company := Company(companyName == "Intel") from world.getCompanies()
end

rule "BMWCarsToPerson"
when
    $world : World()

    $company : Company()

    getBalance($world, $company)
    /*$company : Company() from $world.getCompanies()*/

    $manager : Manager() from $company.getManagers()
        exists Car(name == BrandOfCar.BMW) from $manager.getCars()

    $bmwCarsFromManager : Car(
        name == BrandOfCar.BMW
        ) from $manager.getCars()

    $person : Person(
        name == "Elvis"
        ) from $world.getPersons()

    /*$listMageners : List() from $manager*/

then
end

1 个答案:

答案 0 :(得分:0)

您不应该(也不能)使用查询来执行此简单任务。取代

$company : Company()
getBalance($world, $company)

通过

$company: Company( companyName == "Intel" ) from $world.getCompanies()