2 Replies Latest reply on Aug 27, 2002 6:03 PM by dsundstrom

    <b>Incorrect</b> <i>ObjectNotFoundException</i> message in J

    soeiro

      Hello All

      I have written a simple query using CMP2.0 (JBOSS 3.0.1) and it is throwing javax.ejb.ObjectNotFoundException: No such entity! without any reason. The problem is that the entity being searched for does exist, and so does its record in the database.

      Is this a bug? Or is there something new that needs to be specified in a find method that weren't required in JBoss previous versions?

      The code is the following:

      (...)
      BuildingLocal building=buildingHome.findByAlias("BALIAS");
      (..)

      The deployment descriptor follows:


      &lt;query&gt;
      &lt;query-method&gt;
      &lt;method-name&gt;findByAlias&lt;/method-name&gt;
      &lt;method-params&gt;
      &lt;method-param&gt;java.lang.String&lt;/method-param&gt;
      &lt;/method-params&gt;
      &lt;/query-method&gt;
      &lt;result-type-mapping&gt;Local&lt;/result-type-mapping&gt;
      &lt;ejb-ql&gt;&lt;![CDATA[SELECT OBJECT(b) FROM Building b WHERE b.alias = ?1]]&gt;&lt;/ejb-ql&gt;
      &lt;/query&gt;



      The generated SQL is:

      SELECT t0_b.COD_BUILDING FROM BUILDING t0_b WHERE t0_b.ALIAS = ?

      When I take the generated SQL fragment and run it against the Oracle Database, it correctly returns just the desired COD_BUILDING (which is the primery key). The colunm BUILDING.ALIAS is UNIQUE (doesn't have duplicated values).

      Does anybody know how to fix it?
      Thanks,
      Luis JB Soeiro

        • 1. Re: [b]Incorrect[/b] ObjectNotFoundException message in Jbos
          soeiro

          Sorry for the TAGS. I thought the forum accepted them and they would make things easier to read. The repost follows:

          Hello All

          I have written a simple query using CMP2.0 (JBOSS 3.0.1) and it is throwing javax.ejb.ObjectNotFoundException: No such entity! without any reason. The problem is that the entity being searched for does exist, and so does its record in the database.

          Is this a bug? Or is there something new that needs to be specified in a find method that weren't required in JBoss previous versions?

          The code is the following:

          (...)
          BuildingLocal building=buildingHome.findByAlias("BALIAS");
          (..)

          The deployment descriptor follows:


          <query-method>
          <method-name>findByAlias</method-name>
          <method-params>
          <method-param>java.lang.String</method-param>
          </method-params>
          </query-method>
          <result-type-mapping>Local</result-type-mapping>
          <ejb-ql><![CDATA[SELECT OBJECT(b) FROM Building b WHERE b.alias = ?1]]></ejb-ql>


          The generated SQL is:

          SELECT t0_b.COD_BUILDING FROM BUILDING t0_b WHERE t0_b.ALIAS = ?
          When I take the generated SQL fragment and run it against the Oracle Database, it returns just the desired COD_BUILDING (which is the primery key). The colunm BUILDING.ALIAS is UNIQUE (doesn't have duplicated values).

          Does anybody know how to fix it?

          Thanks,
          Luis JB Soeiro

          • 2. Re: [b]Incorrect[/b] ObjectNotFoundException message in Jbos
            dsundstrom

            Are you sure you are connecting to you oracle database? You can try turning the log level upto trace to see the parameters being set and the results loaded. If that doesn't work try adding some debug statements to JDBCAbstractQueryCommand.