Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-3700

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • No Release
    • JBossAS-4.0.4.GA
    • CMP service
    • None

    Description

      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>

      Attachments

        Activity

          People

            olubyans@redhat.com Alexey Loubyansky
            anajavi anajavi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: