[rules-users] Dealing with Complex objects in Drools

Mark Proctor mproctor at codehaus.org
Wed Jan 2 23:10:02 EST 2008


JimmyM wrote:
> There was an error in the sample code i posted earlier. 
> objList should have been objList2
>
> $o2 : Object2(objList2.field1 != null) from $o1.object2
>   
I assume that objList2 is a collection? If so how can you access a field 
on a collection, you can't. $o1.object2 is returning an object
not a collection, which means it'll pattern match against that single 
object. Remember I said that the 'from' expression must
return a collection, if necessary you'll need to chain the 'from's.
> this also returns the error "unable to resolve property: field1"
>
> Mark Proctor wrote:
>   
>>    
>> make sure the 'from' expression returns a collection, then this will do 
>> what you want.
>>
>>
>>     
> also when i use this instead (java.util.Arraylist has been imported):
>
> $o2 : ArrayList(objList2.field1 != null) from $o1.object2
>
> the error is:
>
> unable to resolve property: unable to resolve token: objList2.field1 
>
> I've inserted only the base object (object1) into working memory. 
> For some reason i cant access attributes deeper than object 2. 
>
> What am i doing wrong? 
>
>
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080103/2157487c/attachment.html 


More information about the rules-users mailing list