Declaring Stateful Relations

Stateful relations have the same methods as stateless ones, the main difference is that wherever you have a Query[A] in a stateless
becomes an Iterable[A] in a stateful relation.

Stateful relations are defined exactly the same way as their stateless counterpart, with the exception that the leftStateful and rightStateful methods are
invoke instead of left and right :

StatefulOneToMany and StatefulManyToOne

Methods in stateful relations are very similar than their stateless counterpart, their signatures are slightly different, and have a refresh method. Note the relation property, it is the stateless relation objects that provides the persistence related functionality. A stateful relation is in fact a wrapper over a stateless one, with caching.

StatefulManyToMany

The similarity between StatefulManyToMany and ManyToMany is also very apparent :