OpenJPA
  1. OpenJPA
  2. OPENJPA-2160

jest findcommand compound/composite primary keys

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.4.0
    • Component/s: jpa
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      jest find command with compound/composite primary key
      http://localhost:8080/openjpa_jest/jest/find/format=json?type=FAKTUREN&FBJ=2012&FNR=4

      diff

      23d22
      < import java.lang.reflect.Modifier;
      31d29
      < import java.util.Set;
      33d30
      < import org.apache.openjpa.enhance.PCRegistry;
      36d32
      < import org.apache.openjpa.meta.FieldMetaData;
      39,40d34
      < import org.apache.openjpa.util.ObjectId;
      < import org.apache.openjpa.lib.log.Log;
      78,82c72,74
      < Object[] keys_obj=parameters.keySet().toArray();
      < FieldMetaData[] fmds=meta.getPrimaryKeyFields();
      < if(fmds.length!=parameters.size())
      < {
      < throw new ProcessingException(ctx,new Exception("number of primaryKeys "fmds.length" differs from number of arguments "+parameters.size()));

      > Iterator<Map.Entry<String,String>> params = parameters.entrySet().iterator();
      > for (int i = 0; i < parameters.size(); i++) {
      > pks[i] = params.next().getKey();
      84,104d75
      < for(int i=0;i<fmds.length;i++)
      < {
      < FieldMetaData fmd=fmds[i];
      < String shrtnm=fmd.getName();
      < int idx=fmd.getIndex();
      < boolean prmsContainName=parameters.containsKey(shrtnm);
      < if(prmsContainName)
      <

      { < String prm_val=parameters.get(shrtnm); < pks[i]=prm_val; < ctx.log(Log.INFO,"tshvr4 FindCommand process setting pks "+i+" shrtnm="+shrtnm+" to "+prm_val); < }

      < else
      < {
      < pks[i]=keys_obj[i];
      < if(i>0)
      <

      { < throw new ProcessingException(ctx,new Exception("if more than 1 primaryKey parm value,primaryKey parm value should be coded as primaryKeyField=primaryKeyValue because arguments are collected into map which does not respect sequence")); < }

      < }
      < }
      106,109d76
      < if(oid instanceof ObjectId)
      <

      { < oid=((ObjectId)oid).getIdObject(); < }
      1. findcommand.diff
        2 kB
        Herman Vierendeels

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Herman Vierendeels
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development