ValueLoadContext on External Entities

Hello

I’m trying to execute a JPQL query like in your example:

ValueLoadContext context = ValueLoadContext.create()
.setQuery(ValueLoadContext.createQuery(
"select o.customer, sum(o.amount) from demo$Order o " +
“where o.date >= :date group by o.customer”)
.setParameter(“date”, orderDate))
.addProperty(“customer”)
.addProperty(“sum”);
List list = dataManager.loadValues(context);

Only problem is that in my case that table “order” is in an external SQL Server DB and I get “The abstract schema type ‘…’ is unknown” as an error. Is this a limitation?
Strange because I can use LoadContext( that is read entities) but no ValueLoadContext seems to work on that table.

Thanks,
Pedro

Hi Pedro,
This is really strange. Are you sure you work with the same entity demo$Order in both cases?

Hi Konstantin

Note that my entity is not named “order” it’s just that is exactly like your example above.
And yes, with that entity in an external (additional) datasource LoadContext works but ValueLoadContext does not.
One maybe important thing is that external “entity” is based on a SQL View.
By the way, your example works perfectly with entity’s in the internal datasource.
I spent a day trying to solve the problem without sucess. Now I’m working on an external webservice so I can read those groupings in my Cuba program.

Thanks,
Pedro

Ah, now I see. I didn’t understand from your first message that by “external” you mean an additional data store.
For ValueLoadContext you have to specify the data store name explicitly (if it’s not the main data store). So this should work:

ValueLoadContext context = ValueLoadContext.create()
    .setStoreName("myStore")
    .setQuery(ValueLoadContext.createQuery(
        "select o.customer, sum(o.amount) from demo$Order o " +
        "where o.date >= :date group by o.customer")
    .setParameter("date", orderDate))
    .addProperty("customer")
    .addProperty("sum");
List<KeyValueEntity> list = dataManager.loadValues(context);

The store cannot be determined automatically because we don’t specify a concrete entity when creating ValueLoadContext.

Thank you, that sure works.

You must agree that this is not very well documented,right?

By the way do you have any sample on consuming web-services?, I have a working project on javax.xml.soap.SOAPConnectionFactory (no luck on OData) but don’t believe how ugly it looks.

Thanks again

Agree, will mention this in the docs.

No, sorry. But I think it’s not directly related to CUBA, must be something on the internet.