Ability to specify Join Queries predicates with custom type mappings instead

24 views
Skip to first unread message

Athanasios Viennas

unread,
Mar 27, 2019, 9:04:13 AM3/27/19
to cqengine-discuss
Hello, is it possible to define cqengine join queries on custom types rather than their relevant key types? Assuming that we have to use a "Country" member property in a "Destination" class rather than a countryId property that represents it's key reference. Fetching the query level entity objects one has to do further lookups to fetch the underlying countries. One "dirty" workaround could be to have both the Country key and the Country member itself coexist in Destination class but that would be way too ugly and impractical.

Niall Gallagher

unread,
Mar 27, 2019, 4:27:20 PM3/27/19
to cqengine...@googlegroups.com
The short and probably the best answer is basically no :) You are probably better off to stick with using countryId for the join. 

The long answer is as follows...

I'm not sure that it's exactly what you want, but for the Destination, you don't need to actually add a Country object as a field inside the Destination.

You can write a _virtual attribute_ for the Desination which returns a Country.

In that attribute, you could perhaps access the other IndexedCollection for Countries and retrieve the Country object whose countryId is in the Destination object.

There are downsides to this approach though, namely that if you add an index on that virtual Country attribute used with the indexedCollection<Destination>, then that index won't be kept up to date with changes in the IndexedCollection<Country>.


Hope that helps!
Niall

On Wed, 27 Mar 2019, 13:04 Athanasios Viennas, <athanasio...@gmail.com> wrote:
Hello, is it possible to define cqengine join queries on custom types rather than their relevant key types? Assuming that we have to use a "Country" member property in a "Destination" class rather than a countryId property that represents it's key reference. Fetching the query level entity objects one has to do further lookups to fetch the underlying countries.  One "dirty" workaround could be to have both the Country key and the Country member itself coexist in Destination class but that would be way too ugly and impractical.

--
-- You received this message because you are subscribed to the "cqengine-discuss" group.
http://groups.google.com/group/cqengine-discuss
---
You received this message because you are subscribed to the Google Groups "cqengine-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cqengine-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Athanasios Viennas

unread,
Mar 28, 2019, 5:32:53 AM3/28/19
to cqengine...@googlegroups.com
Hello, thank you very much for the follow up. I was almost certain that this would not be possible. I currently specify longs of the associated entitiy ids. In terms of the intended functionality of fetching a different entity in the association graph  i.e. assuming the following chained associations [Quote -> Destination -> Country] AND [Destination -> Zone -> Courier] and having a query returning Quotes with criteria on virtually all participating entities is it possible to fetch a Courier object? 

greetings!


Reply all
Reply to author
Forward
0 new messages