I actually have something similar. All of our classes are JPA entities. So I get a hold of the JAR that contains all the class definitions and generate traversal rules to spider out the object model. I look for @Entity, @MapperSuperclass, @Emeddeable, etc. This handles 1-1, 1-many, many-1, and many-many.<br>
<br>To asset 1 object and see it follow all the relationships is pretty wild! The only problem is, you sometimes don&#39;t want to have all the relationships followed, or else you could end up with half the DB in memory. To solve this, I have TraversalPolicy facts that define when a relationship should be followed. There are default policies that go to a depth of 3 in every direction. Then you can define rules in Guvnor to allow for more fine grained traversal under certain circumstances.<br>
<br>dave<br><br><div class="gmail_quote">On Fri, Dec 5, 2008 at 11:09 PM, Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I thought of a simple, yet powerful idea, anyone want to give this ago? It will be the start of making ontologies more sanily usable for java developers.<br>
<br>
Person<br>
 &nbsp;@relation(name=&quot;OwnerPetRelation&quot;, verb=&quot;IsOwnerOf&quot;)<br>
 &nbsp; Set&lt;Pet&gt; pets;<br>
<br>
Pet<br>
 &nbsp;@relation(name=&quot;OwnerPetRelation&quot;, verb=&quot;IsOwnedByf&quot;)<br>
 &nbsp; Person owner;<br>
<br>
<br>
IsOwnerOf and IsOwnedBy do not live on the classpath. The engine detects those annotations and generates them as internal classes. Or actually it can be one class, where it&#39;s able to use the two keywords to reference that class in either direction. When you insert your Persons and Pets, the relations are automatically inserted too (assuming there are rules that use them). This allows people to more naturally explore the relational aspect of their data, without having to create and insert the relations themselves. Once a Relation is being maintained by the engine, any updates to the underlying collection will result in relations being added and removed.<br>

<br>
If we build in relation inferrence, to avoid the extra binding, it would mean that by simply annotating their classes people can do the following (Assuming Cat is a type of Pet):<br>
<br>
When<br>
 &nbsp; Person( location == London ) IsOwnerOf() Cat( color == &quot;Tabby&quot;)<br>
 &nbsp; ....<br>
<br>
The above will get all my london people and their tabby cats. The simply placement of the IsOwnerOf() pattern, would be nice if () was optioal, would constrain the Cat to those related to the Owner. i.e. the short hand equivalent of:<br>

$p : Person( location == London ) IsOwnerOf( owner == $p, $c : Cat ) Cat( this == $c, color == &quot;Tabby&quot;)<br>
<br>
I think that&#39;s powerful and provides for a hyrbid OO and Relational modelling approaches, &nbsp;asthey can still use graph notation:<br>
person.pets[0].color == &quot;tabby&quot;<br>
<br>
This also solves the question that people always ask, how do I insert my collection. With that in place there would still be plenty more to do, like constraints, but it would be a start to improving Drools&#39; relationahip programming &quot;out of the box&quot; capabilities. So who&#39;s game?<br>

<br>
Mark<br>
<br>
<br>
<br>
_______________________________________________<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>
</blockquote></div><br>