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

CMP findByPrimaryKey() broken for composite primary keys

XMLWordPrintable

    • Icon: Patch Patch
    • Resolution: Obsolete
    • Icon: Major Major
    • No Release
    • JBossAS-5.0.0.CR1
    • CMP service
    • None

      findByPrimaryKey() in CMP for an entity bean will re-use the first property as query parameter of a composite primary key for all fields in the SQL query. Our code worked in JBoss 3.2.3 and got broken in 5.0.0CR1.

      In ejb-jar.xml we have

      • prim-key-class
      • primkey-field

      the prim-key-class exposes 3 properties (1 string, 2 integers). Through tracing and debugging we saw that the query gets constructed and parameter types are inferred correctly.

      We compared QueryParameter.java from 3.2.3, 5.0.0 CR1 and v85552 (trunk as of today) and think that functionality got lost (please not the additional "else" for the "property != null" case. We therefore propose the following patch (which at least solved our problem):

      http://anonsvn.jboss.org/repos/jbossas/trunk/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java

      — QueryParameter.java (Revision 85552)
      +++ QueryParameter.java (Arbeitskopie)
      @@ -320,10 +320,18 @@
      }
      arg = field.getPrimaryKeyValue(arg);

      • // use mapper
      • final JDBCType jdbcType = field.getJDBCType();
      • arg = jdbcType.getColumnValue(0, arg);
      • param = jdbcType.getParameterSetter()[0];
        + if(property != null)
        + { + arg = property.getColumnValue(arg); + param = property.getParameterSetter(); + }


        + else
        +

        { + // use mapper + final JDBCType jdbcType = field.getJDBCType(); + arg = jdbcType.getColumnValue(0, arg); + param = jdbcType.getParameterSetter()[0]; + }


        }
        else if(property != null)
        {

      (this was original created here: https://jira.jboss.org/jira/browse/ASPATCH-411)

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

                Created:
                Updated:
                Resolved: