Hi,
I want to load a KeyValueEntity
where email
s have a many to one relationship to the user
s but not every user
needs to have a email
.
So I have the following in the data
part of the descriptor.
<keyValueCollection id="usersDc">
<properties>
<property name="user" class="com.acme.test.user.User"/>
<property name="email" class="com.acme.test.user.Email"/>
</properties>
<loader id="usersDl">
<query>
<![CDATA[select u from myPrj_User u LEFT JOIN u.emails e ON e.from = :from]]>
<condition>
<c:jpql>
<c:where>u.role = :role</c:where>
</c:jpql>
</condition>
</query>
</loader>
</keyValueCollection>
In the layout
part I have a group table that works so far.
<groupTable id="usersTable"
dataContainer="usersDc">
<columns>
<column id="user.name"/>
<column id="email.adress"/>
</columns>
</groupTable>
If I load the data with the dataManager
it works fine. But I’d like to define the query in the descriptor. That’s how I do it with dataManager
with given query
, role
and from
.
final List<KeyValueEntity> users;
users = dataManager.loadValues(query).parameter("role", role).parameter("from", from).properties("user","email").list()
usersDc.setItems(users);
Really nice would be just to use the dataLoader
like this. But I don’t know how I declare the properties
and without declaring the properties
I only get the user
s but no email
s.
usersDl.setParameter("role", role);
usersDl.setParameter("from", from);
usersDl.load();
I can load the query from the dataLoader
but that one doesn’t contain the conditions declared with <c:jpql>
in the descriptor.
usersDl.getQuery()
What’s the best practice to do that?
Regards