Details
-
Bug
-
Resolution: Obsolete
-
Major
-
JBossAS-4.0.4.GA
-
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)
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(
)]]></where>
</declared-sql>
</query>