[coldbox-3.8.1] ORM Dynamic Finders & Property Names Containing "and/or"

This might be documented somewhere but I ran across a problem today when trying to use the Dynamic Finders with a property named Port which contained the substring “or” in it. The message received was:

The property you requested P is not a valid property in the Nifty entity

My line of code was called from a handler was:
niftyService.findByPort(port).getID();

Apparently if you have entity properties that contain the substring “or” or “and” then the dynamic finder thinks you are specifying additional criteria.

Is there a way to get around this while still using Dynamic Finders?

I just ended up creating an actual niftyService.cfc and using Criteria Builder instead…but hoping there is a better way?

niftyService.cfc

`
component extends=“coldbox.system.orm.hibernate.VirtualEntityService” singleton {

// Dependency Injection
property name=“niftyService” inject=“entityService:Nifty”;

/**

  • Constructor
    */
    public NiftyService function init(){
    super.init(entityName=“Nifty”);
    return this;
    }

/**

  • Returns a Nifty object based on the Port provided
    */
    any function getNiftyByPort(port) {

var c = niftyService.newCriteria();
var nifty = c.eq(“port”, c.convertValueToJavaType( propertyName=“port”, value=port )).get();

return nifty;
}

}
`

New call from the handler:

niftyService.getNiftyByPort(port).getID();

Should this

niftyService.findByPort(port).getID();

be

niftyService.findByPort(“port”).getID();

Hey thanks for the reply, Andrew. I should have been more clear.

I was calling it like this:
var port = 8080; niftyService.findByPort(port).getID();

But the problem appears to be where I highlighted in yellow above.

Probably also likely to fail:
findByHandle(a); findBySport(b); findByHandleAndSportAndName(a,b,c);

Ok, yeah that is what you get when you try to anticipate things like

findByXXXXorYYYYandFFFF()

I’ve never looked at that code, but it seems like there’s no reason not to be able to work around that. If the string is parsed from left to right and the code looks for full property names first starting with the longest to the shortest property name, THEN looks for a keyword like and/or then it should fix that.

Who wants to do a pull request!?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

This should now be fixed on the development branch of the cborm module. https://github.com/ColdBox/cbox-cborm/pull/4#event-195086312

Still having some problems with this now that I switched to the cborm module in CB4 (though I doubt it’s due specifically to that, I just haven’t tested this functionality in a while)

Opened an issue in cbox-cborm, probably an easy fix on the RegEx but I haven’t been able to dig it out yet.

Thanks!