I have 2 questions regarding filters for the fiber data model:
Is it possible to retrieve data other than the entities defined in the data model? For example, I would like to be able to retrieve the average of some property in my datamodel. I have tried to create a filter with a jpql query to do that like:
<filter name="getAveragePrice"> <query><![CDATA[jpql:select avg(o.price) from Orders o]]></query> </filter>
But when I try to get that fill I get the error:
The item of type, 'java.lang.Double', passed to the assembler does not match the assembler's configured entity type, 'MyPackage.package2.Orders'. To convert 'flex.messaging.io.amf.ASObject' to a strong type automatically, set the item-class in the destination. null
Does anyone know how to solve this problem?
Further, I have two entities with an association :
When I deploy this to the server I get 2 table and a foreign key from orders to customer as expected. When a get a customer from the service I can access all its orders. However, because my dataset is rather large (> 1000000 records), I would like to be able to specify a subset of the order that are put in the orders property. Something like (in sql)
select c.*, o.* from customer c join orders o on (o.customer_ID = c.ID) where o.price > 1000;
No, you cannot return anything other than a collection of entities from a filter. However, you can certainly create a Remoting destination and use mx:RemoteObject to call a function that returns this kind of data.
As for limiting the number of orders that show up in a Customer entity, you can set this to be "load-on-demand", which is a feature of LCDS that will not load the associated data until it is referenced. You can combine that with paging to limit the number of orders that are brought over the wire at any one time.