1 Reply Latest reply on Jun 12, 2002 6:00 PM by 3004

    Weird Behavior

    3004
      I'm trying to use the contains access to make a query but JDO, here is my
      code : ( ignores the variables )

      extent = pm.getExtent( Permission.class, false );
      query = pm.newQuery( Permission.class, extent,
      "permissionGroupMap.contains(pgMap) & pgMap.userGroup.groupOid == 1"
      );
      query.declareImports("import com.verizon.common.dataobjects.*;");
      query.declareVariables("PermissionGroupMap pgMap");
      Collection per = (Collection)query.execute();
      Iterator iter = per.iterator();
      for (;iter.hasNext();) {
      Permission permission = (Permission)iter.next();
      System.out.println( permission.getName() );
      }

      Here are my classes :

      public class Permission {

           // Class attributes
           private java.math.BigDecimal visibility;
           private java.lang.String name;
           private java.lang.String userId;
           private java.math.BigDecimal permissionOid;
           private java.math.BigDecimal versionOid;
           private java.sql.Timestamp timestamp;
           // N elements in a 1-N relationship
           private Collection permissionGroupMap = new ArrayList();

      public class PermissionGroupMap {

           // Class attributes
           private java.math.BigDecimal permissionGroupMapOid;
           private java.lang.String userId;
           private java.sql.Timestamp timestamp;
           private Permission permission;
           private UserGroup userGroup;

      and the JDO file :

      <class identity-type="application" name="UserGroup"
      objectid-class="UserGroupKey" requires-extent="false">
      <extension key="table" value="USER_GROUP" vendor-name="kodo" />
      <extension key="lock-column" value="jdolock" vendor-name="kodo" />
      <extension key="class-column" value="none" vendor-name="kodo" />
      <field persistence-modifier="persistent" name="name"
      primary-key="false" null-value="none">
      <extension key="data-column" value="NAME" vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="userId"
      primary-key="false" null-value="none">
      <extension key="data-column" value="USER_ID" vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="groupOid"
      primary-key="true" null-value="exception">
      <extension key="data-column" value="GROUP_OID" vendor-name="kodo"
      />
      </field>
      <field persistence-modifier="persistent" name="timestamp"
      primary-key="false" null-value="none">
      <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
      />
      </field>
      <field name="permissionGroupMap">
      <Collection element-type="PermissionGroupMap" />
      <extension key="inverse" value="userGroup" vendor-name="kodo" />
      </field>
      </class>
      <class identity-type="application" name="PermissionGroupMap"
      objectid-class="PermissionGroupMapKey" requires-extent="false">
      <extension key="table" value="PERMISSION_GROUP_MAP"
      vendor-name="kodo" />
      <extension key="lock-column" value="jdolock" vendor-name="kodo" />
      <extension key="class-column" value="none" vendor-name="kodo" />
      <field persistence-modifier="persistent"
      name="permissionGroupMapOid" primary-key="true" null-value="exception">
      <extension key="data-column" value="PERMISSION_GROUP_MAP_OID"
      vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="userId"
      primary-key="false" null-value="none">
      <extension key="data-column" value="USER_ID" vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="timestamp"
      primary-key="false" null-value="none">
      <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
      />
      </field>
      <field name="permission">
      <extension key="versionOid-data-column" value="VERSION_OID"
      vendor-name="kodo" />
      <extension key="permissionOid-data-column" value="PERMISSION_OID"
      vendor-name="kodo" />
      </field>
      <field name="userGroup">
      <extension key="groupOid-data-column" value="GROUP_OID"
      vendor-name="kodo" />
      </field>
      </class>
      <class identity-type="application" name="Permission"
      objectid-class="PermissionKey" requires-extent="false">
      <extension key="table" value="PERMISSION" vendor-name="kodo" />
      <extension key="lock-column" value="jdolock" vendor-name="kodo" />
      <extension key="class-column" value="none" vendor-name="kodo" />
      <field persistence-modifier="persistent" name="visibility"
      primary-key="false" null-value="none">
      <extension key="data-column" value="VISIBILITY" vendor-name="kodo"
      />
      </field>
      <field persistence-modifier="persistent" name="name"
      primary-key="false" null-value="none">
      <extension key="data-column" value="NAME" vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="userId"
      primary-key="false" null-value="none">
      <extension key="data-column" value="USER_ID" vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="permissionOid"
      primary-key="true" null-value="exception">
      <extension key="data-column" value="PERMISSION_OID"
      vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="versionOid"
      primary-key="true" null-value="exception">
      <extension key="data-column" value="VERSION_OID"
      vendor-name="kodo" />
      </field>
      <field persistence-modifier="persistent" name="timestamp"
      primary-key="false" null-value="none">
      <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
      />
      </field>
      <field name="permissionGroupMap">
      <Collection element-type="PermissionGroupMap" />
      <extension key="inverse" value="permission" vendor-name="kodo" />
      </field>
      </class>

      here is the exception :

      avax.jdo.JDOUserException: The field "userGroup" of type "class
      com.verizon.common.dataobjects.Permission" does not exist or is not
      persistent.
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.parsePath(JDBCExpressionFactory.java:766)
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.finish(JDBCExpressionFactory.java:696)
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.getStrings(JDBCExpressionFactory.java:672)
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$ValueImpl.compare(JDBCExpressionFactory.java:379)
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory.equal(JDBCExpressionFactory.java:85)
           at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:583)
           at
      com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:678)
           at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:654)
           at
      com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:678)
           at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:530)
           at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:502)
           at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:468)
           at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:190)
           at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:342)
           at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:308)
           at com.verizon.framework.datalayer.testJDO.testUser(Unknown Source)
           at com.verizon.framework.datalayer.testJDO.main(Unknown Source)


        • 1. Re: Weird Behavior
          3004
          That is a strange error.

          I'm not sure if this is the cause of the error, but I noticed that your
          metadata uses the 'Collection' element to describe the 'permissionGroupMap'
          field. JDO expects a 'collection' element (note the case), so that might be
          causing issues that are throwing our parser off somehow.

          -Patrick


          On 6/12/02 12:28 AM, "Manuel Ledesma" <manuel.ledesma@verizon.com> wrote:
          I'm trying to use the contains access to make a query but JDO, here is my
          code : ( ignores the variables )

          extent = pm.getExtent( Permission.class, false );
          query = pm.newQuery( Permission.class, extent,
          "permissionGroupMap.contains(pgMap) & pgMap.userGroup.groupOid == 1"
          );
          query.declareImports("import com.verizon.common.dataobjects.*;");
          query.declareVariables("PermissionGroupMap pgMap");
          Collection per = (Collection)query.execute();
          Iterator iter = per.iterator();
          for (;iter.hasNext();) {
          Permission permission = (Permission)iter.next();
          System.out.println( permission.getName() );
          }

          Here are my classes :

          public class Permission {

          // Class attributes
          private java.math.BigDecimal visibility;
          private java.lang.String name;
          private java.lang.String userId;
          private java.math.BigDecimal permissionOid;
          private java.math.BigDecimal versionOid;
          private java.sql.Timestamp timestamp;
          // N elements in a 1-N relationship
          private Collection permissionGroupMap = new ArrayList();

          public class PermissionGroupMap {

          // Class attributes
          private java.math.BigDecimal permissionGroupMapOid;
          private java.lang.String userId;
          private java.sql.Timestamp timestamp;
          private Permission permission;
          private UserGroup userGroup;

          and the JDO file :

          <class identity-type="application" name="UserGroup"
          objectid-class="UserGroupKey" requires-extent="false">
          <extension key="table" value="USER_GROUP" vendor-name="kodo" />
          <extension key="lock-column" value="jdolock" vendor-name="kodo" />
          <extension key="class-column" value="none" vendor-name="kodo" />
          <field persistence-modifier="persistent" name="name"
          primary-key="false" null-value="none">
          <extension key="data-column" value="NAME" vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="userId"
          primary-key="false" null-value="none">
          <extension key="data-column" value="USER_ID" vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="groupOid"
          primary-key="true" null-value="exception">
          <extension key="data-column" value="GROUP_OID" vendor-name="kodo"
          />
          </field>
          <field persistence-modifier="persistent" name="timestamp"
          primary-key="false" null-value="none">
          <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
          />
          </field>
          <field name="permissionGroupMap">
          <Collection element-type="PermissionGroupMap" />
          <extension key="inverse" value="userGroup" vendor-name="kodo" />
          </field>
          </class>
          <class identity-type="application" name="PermissionGroupMap"
          objectid-class="PermissionGroupMapKey" requires-extent="false">
          <extension key="table" value="PERMISSION_GROUP_MAP"
          vendor-name="kodo" />
          <extension key="lock-column" value="jdolock" vendor-name="kodo" />
          <extension key="class-column" value="none" vendor-name="kodo" />
          <field persistence-modifier="persistent"
          name="permissionGroupMapOid" primary-key="true" null-value="exception">
          <extension key="data-column" value="PERMISSION_GROUP_MAP_OID"
          vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="userId"
          primary-key="false" null-value="none">
          <extension key="data-column" value="USER_ID" vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="timestamp"
          primary-key="false" null-value="none">
          <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
          />
          </field>
          <field name="permission">
          <extension key="versionOid-data-column" value="VERSION_OID"
          vendor-name="kodo" />
          <extension key="permissionOid-data-column" value="PERMISSION_OID"
          vendor-name="kodo" />
          </field>
          <field name="userGroup">
          <extension key="groupOid-data-column" value="GROUP_OID"
          vendor-name="kodo" />
          </field>
          </class>
          <class identity-type="application" name="Permission"
          objectid-class="PermissionKey" requires-extent="false">
          <extension key="table" value="PERMISSION" vendor-name="kodo" />
          <extension key="lock-column" value="jdolock" vendor-name="kodo" />
          <extension key="class-column" value="none" vendor-name="kodo" />
          <field persistence-modifier="persistent" name="visibility"
          primary-key="false" null-value="none">
          <extension key="data-column" value="VISIBILITY" vendor-name="kodo"
          />
          </field>
          <field persistence-modifier="persistent" name="name"
          primary-key="false" null-value="none">
          <extension key="data-column" value="NAME" vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="userId"
          primary-key="false" null-value="none">
          <extension key="data-column" value="USER_ID" vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="permissionOid"
          primary-key="true" null-value="exception">
          <extension key="data-column" value="PERMISSION_OID"
          vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="versionOid"
          primary-key="true" null-value="exception">
          <extension key="data-column" value="VERSION_OID"
          vendor-name="kodo" />
          </field>
          <field persistence-modifier="persistent" name="timestamp"
          primary-key="false" null-value="none">
          <extension key="data-column" value="TIMESTAMP" vendor-name="kodo"
          />
          </field>
          <field name="permissionGroupMap">
          <Collection element-type="PermissionGroupMap" />
          <extension key="inverse" value="permission" vendor-name="kodo" />
          </field>
          </class>

          here is the exception :

          avax.jdo.JDOUserException: The field "userGroup" of type "class
          com.verizon.common.dataobjects.Permission" does not exist or is not
          persistent.
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.parsePat
          h(JDBCExpressionFactory.java:766)
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.finish(J
          DBCExpressionFactory.java:696)
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$PathImpl.getStrin
          gs(JDBCExpressionFactory.java:672)
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory$ValueImpl.compare
          (JDBCExpressionFactory.java:379)
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExpressionFactory.equal(JDBCExpress
          ionFactory.java:85)
          at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:583)
          at
          com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:678)
          at com.solarmetric.kodo.query.FilterParser.eval(FilterParser.java:654)
          at
          com.solarmetric.kodo.query.FilterParser.getExpression(FilterParser.java:678)
          at com.solarmetric.kodo.query.FilterParser.evaluate(FilterParser.java:530)
          at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:502)
          at com.solarmetric.kodo.query.QueryImpl.getExpression(QueryImpl.java:468)
          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.getExpression(JDBCQuery.java:
          190)
          at com.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:342)
          at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:308)
          at com.verizon.framework.datalayer.testJDO.testUser(Unknown Source)
          at com.verizon.framework.datalayer.testJDO.main(Unknown Source)

          --
          Patrick Linskey pcl@solarmetric.com
          SolarMetric Inc. http://www.solarmetric.com