5 Replies Latest reply on Jul 10, 2003 7:47 AM by Vishal Sharma

    simple finder question

    Joern Newbie

      hi,

      im using cmp and want to know how i define finder methods. have i always to name my finder : findBy+ cmr-field() ?? my logfile (boot.log) autogenerates the finders. if i use an other name for my finders i get an exception. in addition my the autogenerated finders uses there own sql. if i define ejb-ql, it is ignored.

      thx

        • 1. Re: simple finder question
          Joern Newbie

          can somebody help please? why are the finders autogenerated and why is my ejb-ql ignored?


          if the finder has a arbitrary name i get this exception:

          08:38:32,461 DEBUG [JDBCFindEntitiesCommand] Could not create the finder findByE_description, because no matching CMP field was found.
          java.lang.IllegalArgumentException: No finder for this method: findByE_description


          if the finder has a name like the cmp field, it works but my ejb-ql in the ejb-jar.xml is not used.

          08:38:32,445 DEBUG [JDBCFindEntitiesCommand] AutoGenerated finders - Home=interface ejb.interfaces.E_EmotionHome -- LocalHome=null
          08:38:32,445 DEBUG [JDBCFindEntitiesCommand] Save AutoGenerated findAll public abstract java.util.Enumeration ejb.interfaces.E_EmotionHome.findAll() throws javax.ejb.FinderException,java.rmi.RemoteException
          08:38:32,461 DEBUG [JDBCCommand] findAll SQL: SELECT e_id FROM E_Emotion

          • 2. Re: simple finder question
            Juha Lindfors Master

            please post your deployment descriptors

            • 3. Re: simple finder question
              Joern Newbie

              ejb-jar.xml

              <?xml version="1.0"?>
              <ejb-jar>
              <enterprise-beans>

              <ejb-name>E_Emotion</ejb-name>
              ejb.interfaces.E_EmotionHome
              ejb.interfaces.E_EmotionRemote
              <ejb-class>ejb.bean.E_EmotionBean</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>java.lang.Integer</prim-key-class>
              False
              <cmp-version>2.x</cmp-version>
              <abstract-schema-name>E_Emotion</abstract-schema-name>
              <cmp-field>
              <field-name>e_id</field-name>
              </cmp-field>
              <cmp-field>
              <field-name>e_bez</field-name>
              </cmp-field>
              <primkey-field>e_id</primkey-field>


              <query-method>
              <method-name>findByE_description</method-name>
              <method-params>
              <method-param>java.lang.String</method-param>
              </method-params>
              </query-method>
              <ejb-ql>
              <![CDATA[SELECT OBJECT(o) FROM E_Emotion AS o WHERE o.e_bez = ?1]]>
              </ejb-ql>



              <result-type-mapping>Remote</result-type-mapping>
              <query-method>
              <method-name>findAll</method-name>
              <method-params>
              <method-param></method-param>
              </method-params>
              </query-method>
              <ejb-ql>
              <![CDATA[SELECT OBJECT(o) FROM E_Emotion o]]>
              </ejb-ql>


              <result-type-mapping>Remote</result-type-mapping>
              <query-method>
              <method-name>findByE_id</method-name>
              <method-params>
              <method-param>java.Lang.Integer</method-param>
              </method-params>
              </query-method>
              <ejb-ql>
              <![CDATA[SELECT OBJECT(o) FROM E_Emotion o WHERE o.e_id = ?1]]>
              </ejb-ql>



              .
              .
              .

              • 4. Re: simple finder question
                Joern Newbie

                can anybody explain autogenerated finders or has some llinks/informations?

                • 5. Re: simple finder question
                  Vishal Sharma Expert

                  Now , first of all with yr findBy method, i must clarify few points.

                  You cans use findBy method onlu on these scenarios.
                  that is findByPrimayKey()
                  or findBy, other then that is not acceptable as it is being mentioned in EJB specs, if I remember correctly somewhere in Sectio 10.xxx.

                  I am assuming you are using Xdoclet tags for generating descriptors.

                  Now if you use this, and define yr finder method then you still have to specify the query as well, related to this method.
                  And if you do these two steps, then there should not be any problem.

                  I hope this helps :-)