Version 7.0 JPQL session parameter?

Version 6 allowed access to the user session in the datasource query


for example.

Would I be right in assuming this is not supported in the new data loaders?

Hello @ray1

It’s designed to not pass such parameters automatically. In case of containers you have to pass params manually:

Collection container with param:

<collection id="usersDc"
    <loader id="usersDl">
            <![CDATA[select e from sec$User e where e.login = :container$userLogin]]>

Pass param in controller:

private CollectionLoader<User> usersDl;
private UserSession userSession;

private void onInit(InitEvent event) {
    String login = userSession.getUser().getLogin();

    usersDl.setParameter("container$userLogin", login);

You can find more detailed example in our documentation: DeclarativeLoaderParameters mixin


Faced the same problem, IllegalStateException lack of query argument :session$userLogin. 7.1 docs in Query Parameters says that :session$userLogin should be working, but it’s not… Maybe docs need to be updated…

The docs are probably fine. By the looks of it, you’re reading the section on the legacy data API. The new API doesn’t support the session parameters.