Note that there are some explanatory texts on larger screens.

plurals
  1. POGWT Request Factory - Several entity locators for the same entity type
    primarykey
    data
    text
    <p>I want to be able to use different entity locators for the same domain object. I use <code>Twig</code> and it has an option to load an object fully or partially. When I run the lite request <code>fetchRangeLite</code>, the locator <code>TwigLocator</code> is used instead of <code>TwigLiteLocator</code>. My current implementation is:</p> <p>Proxies</p> <pre><code>@ProxyFor(value = MyDomain.class, locator = TwigLocator.class) public interface MyDomainProxy extends EntityProxy {} @ProxyFor(value = MyDomain.class, locator = TwigLiteLocator.class) public interface MyDomainLiteProxy extends EntityProxy {} </code></pre> <p>Request</p> <pre><code>@Service(value = MyDao.class, locator = DaoServiceLocator.class) public interface MyRequest extends RequestContext { Request&lt;List&lt;MyDomainProxy&gt;&gt; fetchRange(Integer start, Integer length); Request&lt;Integer&gt; getCount(); Request&lt;List&lt;MyDomainLiteProxy&gt;&gt; fetchRangeLite(Integer start, Integer length); } </code></pre> <p>DAO</p> <pre><code>public List&lt;MyDomain&gt; fetchRange(Integer start, Integer length) { ... } public List&lt;MyDomain&gt; fetchRangeLite(Integer start, Integer length) { ... } </code></pre> <p><strong>I was expecting the lite locator to be used but it's not the case. So how does RF choose which locator it should use for a specific domain type?</strong></p> <p><strong>UPDATE</strong></p> <p>My domain object is composed by list of lists.</p> <pre><code>public class MyDomain extends DatastoreObject { private List&lt;A&gt; a; } public class A { private List&lt;B&gt; b; } </code></pre> <p>When a proxy of my <code>MyDomain</code> object is sent from the server to the client, <code>Twig</code> also loads all the <code>A</code>'s and all the <code>B</code>'s which takes time. I am only interested by a property in the <code>MyDomain</code> object, that's why I want to use a "lite" locator.</p> <p>TwigLocator</p> <pre><code>@Override public DatastoreObject find(Class&lt; ? extends DatastoreObject&gt; clazz, Long id) { ObjectDatastore myDatastore = datastoreProvider.get(); DatastoreObject object = myDatastore.load(clazz, id); return object; } </code></pre> <p>TwigLiteLocator </p> <pre><code>@Override public DatastoreObject find(Class&lt; ? extends DatastoreObject&gt; clazz, Long id) { ObjectDatastore myDatastore = datastoreProvider.get(); myDatastore.setActivationDepth(0); DatastoreObject object = myDatastore.load(clazz, id); return object; } </code></pre> <p><code>myDatastore.setActivationDepth(0);</code> tells the datastore to load only the properties in <code>MyDomain</code> and not the sublevel (List) properties.</p> <p>The DAO implementation is the same, so the ID and version are the same for both proxies.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload