Hello,
I found some confusing thing while constructing queries.
Let's assume I have a simple model with 2 classes:
public static class Product {
private BigInteger productId;
public Product(int id) {
productId = BigInteger.valueOf((long)id);
}
public void setProductId(BigInteger productId) {
this.productId = productId;
}
public BigInteger getProductId() {
return productId;
}
}
public static class Relation {
private BigInteger productAID;
private Product productB;
public void setProductAID(BigInteger productAID) {
this.productAID = productAID;
}
public BigInteger getProductAID() {
return productAID;
}
public void setProductB(Product productB) {
this.productB = productB;
}
public Product getProductB() {
return productB;
}
}
It's not very sophisticated.
And I have a query:
query "Query_1" (Product $p)
$r : Relation( productAID == $p.productId )
end
The problem is, that, when I want to build a DRL with the query I've got
an error:
org.drools.rule.InvalidRulePackage: Not possible to directly access the
property 'productId' of declaration '$p' since it is not a pattern :
[Rule name=Query_1, agendaGroup=MAIN, salience=0, no-loop=false]
Unable to create restriction '[QualifiedIndentifierRestr: ==
$p.productId ]' for field 'productAID' in the rule 'Query_1' : [Rule
name=Query_1, agendaGroup=MAIN, salience=0, no-loop=false]
The question is: why?
Of course, all types are imported, etc.
Moreover, when I modify the query as a following:
query "Query_1" (Product $p)
$p1 : Product ( ) from $p
$r : Relation( productAID == $p1.productId )
end
then everything works fine.
Is it a desirable behaviour?
I hope the description above is enough to understand the problem, but if
anyone needed full Java source and DRLs, please, let me know.
Best regards,
--
Przemysław Różycki
AMG.net, A Bull Group Company
ul. Łąkowa 29
90-554 Łódź
www.amg.net.pl