[jboss-jira] [JBoss JIRA] Created: (JBAS-3700) Declared SQL Finder does not work with cmp2.x jdbc2 pm

anajavi (JIRA) jira-events at jboss.com
Tue Sep 26 06:16:01 EDT 2006


Declared SQL Finder does not work with cmp2.x jdbc2 pm
------------------------------------------------------

                 Key: JBAS-3700
                 URL: http://jira.jboss.com/jira/browse/JBAS-3700
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: CMP service
    Affects Versions: JBossAS-4.0.4.GA
            Reporter: anajavi
         Assigned To: Alexey Loubyansky


When using declared sql where clause in finder, the generated sql does not contain all the fields of the entity. The cmp2.x jdbc2 pm requires the query to return all the fields. This causes an exception when the finder is invoked.

This is caused by DeclaredSQLQueryCommand.java and method buildSQL:
      if(metadata.getFieldName() == null)
      {
         // we are selecting a full entity
         table = this.entity.getQualifiedTableName();

         // get a list of all fields to be loaded
         // put pk fields in front
         String tableAlias = getTableAlias(alias, from, this.entity.getTableName());
         selectList = SQLUtil.getColumnNamesClause(this.entity.getPrimaryKeyFields(),
            tableAlias,
            new StringBuffer(35)).toString();
      }


Quick fix is to change this.entity.getPrimaryKeyFields() to this.entity.getTableFields().

The configurations:

ejb-jar.xml:
         <query>
            <query-method>
               <method-name>findByNimi</method-name>
               <method-params>
                  <method-param>java.lang.String</method-param>
               </method-params>
            </query-method>
            <ejb-ql><![CDATA[SELECT OBJECT(o) FROM Yritys AS o WHERE o.nimi=?1]]></ejb-ql>
         </query>


jbosscmp-jdbc.xml:
         <query>
                        <description/>
            <query-method>
               <method-name>findByNimi</method-name>
               <method-params>
                  <method-param>java.lang.String</method-param>
               </method-params>
            </query-method>

            <declared-sql>
                <where><![CDATA[upper(nimi) like upper({0})]]></where>
            </declared-sql>
         </query>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list