My feeling after reading this post is that you need to execute a rule, if some child
object exists.
I suggest using the Exists Feature in Drools for doing something like that.
It would be the same thing if you are writing SQL. If you join a Master Table with child
tables you will get as many records as there are child records for each master record.
However, if you only want one master record if there are child record, you would need to
use the exists statement.
Example:
rule "Multiple results set"
when
order: Order
exists ( Invoice from order.invoices)
then
System.out.println("Rule Example (Multiple results set)"+order.getId());
end;
Cheers,
Vikrant
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Mohamed Riyaz
Sent: Monday, September 08, 2008 12:05 PM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Drools ruturn multiple results based on child objects data length
Hi,
In one-to-many relationship object type, Drools generate multiple results based on child
objects data length. ie. No of child records
belongs to parent object. I wanted the RHS part should be executed only if conditions
imposed
on child object satisfies.
I have two facts with 1-* relationship defined in object mapping.
class Invoice{}
class Order{
private Set<Invoice> invoices;
}
I wanted RHS should be executed with only one result irrespective of child records
length.
rule "Multiple results set"
when
order: Order()
invoice : Invoice() from order.invoices
then
System.out.println("Rule Example (Multiple results set)"+order.getId());
end;
Result:
Rule Example (Multiple results set)1000
Rule Example (Multiple results set)1000
Please help me in resolving this issue.
Regards,
Riyaz
MASTEK LTD.
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek
Limited, unless specifically indicated to that effect. Mastek Limited does not accept any
responsibility or liability for it. This e-mail and attachments (if any) transmitted with
it are confidential and/or privileged and solely for the use of the intended person or
entity to which it is addressed. Any review, re-transmission, dissemination or other use
of or taking of any action in reliance upon this information by persons or entities other
than the intended recipient is prohibited. This e-mail and its attachments have been
scanned for the presence of computer viruses. It is the responsibility of the recipient to
run the virus check on e-mails and attachments before opening them. If you have received
this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~