&nbsp; <br>&nbsp;&nbsp; Michal is correct from the point of view of the application. That is required because the actual classes are generated at compile time and not visible to the application classpath.<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; Although, that is not the only way. Inside your rules, they are visible and you instantiate them the same way as you instantiate any other java Pojo:<br>
<br>rule xyz<br>when<br>&nbsp;&nbsp;&nbsp;&nbsp; // sometihng<br>then<br>&nbsp;&nbsp;&nbsp;&nbsp; Person p = new Person();<br>&nbsp;&nbsp;&nbsp;&nbsp; p.setName( &quot;Bob&quot; );<br>&nbsp;&nbsp;&nbsp;&nbsp; insert( p );<br>end<br><br>&nbsp;&nbsp;&nbsp; Also, if you use Guvnor to define your model, Guvnor is capable of generating a jar file for you with the generated classes. This way you can download the jar and add it to the classpath of your application and use it as any POJOs too.<br>
<br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><br><div class="gmail_quote">2009/1/27 Michal Bali <span dir="ltr">&lt;<a href="mailto:michalbali@gmail.com">michalbali@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Look at this unit test for some examples:</div><div><a href="http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java" target="_blank">http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java</a><br>

</div><div><br></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Retrieve the generated fact type</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;FactType cheeseFact = ruleBase.getFactType( &quot;org.drools.generatedbeans.Cheese&quot; );</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Create a new Fact instance</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Object cheese = cheeseFact.newInstance();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set a field value using the more verbose method chain...</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// should we add short cuts?</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.getField( &quot;type&quot; ).getFieldAccessor().setValue( cheese,</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;stilton&quot; );</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.set( cheese,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;type&quot;,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;stilton&quot; );</div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;assertEquals( &quot;stilton&quot;,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cheeseFact.get( cheese,</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;type&quot; ) );</div></div><br><br><div class="gmail_quote"><div>
<div></div><div class="Wj3C7c">On Tue, Jan 27, 2009 at 2:02 AM, Oleg Zenzin <span dir="ltr">&lt;<a href="mailto:zenzin@intalio.com" target="_blank">zenzin@intalio.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c"><p>There&#39;s now possibility to declare facts in the drl, like:<br>
</p><p><font face="courier new,monospace">declare Person<br>
&nbsp;name: String<br>&nbsp;age: int<br>end</font><br></p><p>My question is how do I instantiate this fact object during runtime? Do I still need to have class <font face="courier new,monospace">Person</font> compiled and existing somewhere in classpath, or there&#39;s a helper class which I can use &quot;fake the fact&quot;, something like:</p>


<p><font face="courier new,monospace">&nbsp; FakeFact person = FakeFact(&quot;Person&quot;);<br>&nbsp; person.setField(&quot;name&quot;, &quot;Oleg&quot;);<br>&nbsp; person.setField(&quot;age&quot;, &quot;42&quot;);<br>&nbsp; session.insert(person);</font></p>


<p>Or there&#39;s another nicer way?<br><br></p><p>Thank you,<br>-Oleg Zenzin<br></p>
<br></div></div>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>