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();