[Coldbox 3.8.1] Problems (and solution) with Dynamic finders in BaseORMService

17 views
Skip to first unread message

wbr

unread,
May 20, 2015, 6:03:25 AM5/20/15
to col...@googlegroups.com
Hi, we are using a lot of functionality from BaseORMService, and most of it is very handy

Recently we discovered the Dynamic finders. Example is:

myObj=orm.findbyName("Domain","mycompany.nl");

But in some cases these methods caused mapping errors, telling me my existing Domain component did not exist.
If I used a findWhere method from the same orm library things were OK, like 
myObj = orm.findwhere("Domain",{ name = "mycompany.nl"});

For most other components things were fine, so we had to find differences. In this case we were using multiple datasources, and dynamic finders failed only on the non-default datasources.
I investigated the source code and saw the dynamic finders use HQL, wile the findwhere methods only use EntityLoad. In HQL you have to specify a datasource option if not using a default datasource, so this coud be solved in this way

myObj=orm.findbyName("Domain","mycompany.nl",{datasource="mydatasourcename"});

Maybe documentation can be improved a little, so it is clear that dynamic finders are implemented in a different way compared to the findwhere methods? Specifying this datasource in every call is a workable solution (we do the same with HQL) but not very desirable, 


Or another solution could be:
The findDynamically method already has an options struct for HQL options and an EntityName argument. From this entityname you could determine if a datasource was specified in the Entity definition. If so, it could be added to the options struct.

For now, we returned to the findwhere methods when using non standard datasources. Other syntax, other technique, but same results for exact matches.


Kind regards,

Wil





Curt Gratz

unread,
May 20, 2015, 6:28:42 AM5/20/15
to <coldbox@googlegroups.com>
The reason we can't use entity load is we allow for more complex finders like with this or this etc.   Sorry for the confusion though.

Sent from my Atari 
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/0c36d825-2ab1-42e1-bb96-c86d75d0a706%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wbr

unread,
May 20, 2015, 7:48:50 AM5/20/15
to col...@googlegroups.com


Op woensdag 20 mei 2015 12:28:42 UTC+2 schreef Curt Gratz:
The reason we can't use entity load is we allow for more complex finders like with this or this etc.   Sorry for the confusion though.

No problem :-) We are quite happy with Coldbox, and there are plenty of easy workarounds. I just thought I would share this info with you. Just some mention of this in the docs would already save a lot of debugging. There are many more functions which don't work as expected, at least if you don't realize it is HQL based, such as all count, countwhere, dynamic counters and getAll, 

deleteAll and deleteWhere are also HQL based but here the datasource is included by options.datasource = orm.getEntityDatasource(arguments.entityName);

Wil

Luis Majano

unread,
May 20, 2015, 10:55:10 AM5/20/15
to coldbox

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.

wbr

unread,
May 21, 2015, 4:47:24 AM5/21/15
to col...@googlegroups.com
Ok, I created a login and posted this issue.

Op woensdag 20 mei 2015 16:55:10 UTC+2 schreef Luis Majano:
Reply all
Reply to author
Forward
0 new messages