<br><br>&nbsp;&nbsp; Sibylle,<br><br>&nbsp;&nbsp; Unfortunately, this is the way it was implemented to be, under a kind-of &quot;fail-fast&quot; philosophy we were following. I do think there is value in changing things in 5.0 so that, for instance:<br>
<br>
ProcessModel($activities : activities) from $models<br>
<br>&nbsp;&nbsp; Simply does not match, instead of raises a CCE, in case the model is a TypeModel.<br>&nbsp;&nbsp; But for 4.0.x, that is how things work.<br><br>&nbsp;&nbsp;&nbsp; The only suggestion I can give you is, in your second problem, to not return null on your collections. Simply return empty collections:<br>
<br>class Project {<br>&nbsp;&nbsp; ...<br>&nbsp;&nbsp; public List getModels() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( this.models == null ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Collections.emptyList();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return this.models;<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; ...<br>}<br>&nbsp; <br>
&nbsp;&nbsp; This is usually a good thing, unless you have a specific semantics for null collections in your domain model.<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">2008/6/6 Sibylle Duerr &lt;sibylle.duerr@mymail.ch&gt;:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi there,<br>
<br>
I have three issues, where I&#39;m not sure if these are bugs in drools, or if this is just the way it has to be.<br>
<br>
the used classes in this case are:<br>
<br>
Project<br>
Model<br>
ProcessModel extends Model<br>
<br>
only the Project is in the working memory, because I didn&#39;t want to load all elements due to performance issues (there can be thousends of elements to load at startup).<br>
<br>
if I have the following rule:<br>
<br>
Project($models : models)<br>
ProcessModel($activities : activities) from $models<br>
<br>
there happen to be two problems. if the project does not only contain ProcessModels but also TypeModels or others (all extend Model), this leads to a ClassCastException.<br>
I can solve this by writing the rule as follows:<br>
<br>
Project($models : models)<br>
$m : Model(eval($m instanceof ProcessModel)) from $models<br>
ProcessModel($activities : activities) from $m<br>
<br>
but this is not really nice and I hope there is a better solution for this, is there?<br>
<br>
the second problem this rule gives me, is when the set &#39;models&#39; is empty. that will also throw an exception. to solve this I write:<br>
<br>
$p : Project(eval($p.hasModels()), $models : models)<br>
$m : Model(eval($m instanceof ProcessModel)) from $models<br>
ProcessModel($activities : activities) from $m<br>
<br>
and I need to use this in each case where I have possible empty sets.<br>
<br>
<br>
the last problem I encountered when I tried to load all elements to the working memory and then redefine some rules. used classes:<br>
<br>
Aggregation extends DomainElement<br>
<br>
rule:<br>
<br>
Aggregation(owner.owner != type.owner)<br>
<br>
causes some exception. the root exception is a ClassCastException: ProxyShadowProxy cannot be cast to Aggregation.<br>
when I rewrite the rule as:<br>
<br>
$element : DomainElement(eval($element instanceof Aggregation))<br>
Aggregation(owner.owner != type.owner) from $element<br>
<br>
everything works fine. but that again is not a nice solution.<br>
<br>
any help?<br>
<br>
best regards<br>
sibylle<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>