Uploaded image for project: 'Lucee Development'
  1. LDEV-908

EntityLoadByExample with unique argument fails with Can't cast Null value to value of type [Component]

    Details

    • Type: Bug
    • Status: Deployed
    • Priority: Critical
    • Resolution: Fixed
    • Affects versions: 5.1.0.17
    • Fix versions: 5.3.2.24, Hibernate 3.5.5.75
    • Labels:
      None
    • Environment:

      Windows 10 x64 JRE 1.8.0u92

    • Sprint:
      March 2019, November 2018 Sprint

      Description

      Have a simple persistent property Thing.cfc with a PK and a couple fields, e.g.

      component persistent="true" table="things"  schema="dbo" output="false" {
      
      	property name="thingID" column="thingID" type="string" ormtype="string" fieldtype="id" generator="guid";
      	property name="someForeignKey" column="someForeignKey" type="string" ormtype="string";
      	property name="someOtherForeignKey" column="someOtherForeignKey" type="string" ormtype="string";
      
      }
      

      Then:

      newThing = EntityNew("Thing",{someForeignKey='aValue',someOtherForeignKey='aDifferentValue');
      
      checkForDupes = EntityLoadByExample(newThing,true);
      

      If there are no duplicates, ACF will return null (just as it would with EntityLoadByPK if the PK specified didn't exist).

      Lucee 5.1:

      lucee.runtime.exp.CasterException: Can't cast Null value to value of type [Component] at lucee.runtime.op.Caster.toComponent(Caster.java:3982) at lucee.runtime.op.CastImpl.toComponent(CastImpl.java:1023) at org.lucee.extension.orm.hibernate.CommonUtil.toComponent(CommonUtil.java:179) at org.lucee.extension.orm.hibernate.HibernateORMSession.loadByExample(HibernateORMSession.java:620) at lucee.runtime.functions.orm.EntityLoadByExample.call(EntityLoadByExample.java:33) at coaches.attendance_cfm$cf.call(C:\inetpub\wwwroot\inleague\inleague\coaches\attendance.cfm:38) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:900) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:815) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:810) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:801) at application_cfc$cf.udfCall(C:\inetpub\wwwroot\inleague\demo\Application.cfc:36) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:105) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:337) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:224) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1903) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:422) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:224) at lucee.runtime.listener.ModernAppListener.onRequest(ModernAppListener.java:103) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2267) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2259) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2227) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:845) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:103) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:780) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
      

      If you don't use the 'unique' argument, it will correctly return an empty array, so that is the workaround for the time being.

        Attachments

          Activity

            People

            • Assignee:
              michaeloffner Michael Offner
              Reporter:
              Aquitaine Samuel W. Knowlton
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: