Uploaded image for project: 'OJB'
  1. OJB
  2. OJB-95

Retrieving collections when FK is a VARCHAR

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • 1.0.4
    • 1.1 CVS
    • PB-API
    • None

    Description

      Hi,

      I encountered a weird problem in simply retrieving objects mapped to the following table:

      <class-descriptor class="w4b.com.cassagest.db.Docassiste" table="DOCASSISTE">
      <field-descriptor name="dbprogre" primarykey="true" default-fetch="true" autoincrement="true" sequence-name="public.docassiste_dbprogre_seq" column="DBPROGRE" jdbc-type="INTEGER"/>
      <field-descriptor name="dbcodass" default-fetch="true" column="DBCODASS" jdbc-type="VARCHAR"/>
      <field-descriptor name="dbdocume" default-fetch="true" column="DBDOCUME" jdbc-type="INTEGER"/>
      <field-descriptor name="dbobblig" default-fetch="true" column="DBOBBLIG" jdbc-type="VARCHAR"/>
      <field-descriptor name="dbannota" default-fetch="true" column="DBANNOTA" jdbc-type="CHAR"/>
      <reference-descriptor name="dbcodassRef" class-ref="w4b.com.cassagest.db.Passiste" auto-update="false" auto-delete="false" proxy="false">
      <foreignkey field-ref="dbcodass"/>
      </reference-descriptor>
      <reference-descriptor name="dbdocumeRef" class-ref="w4b.com.cassagest.db.Docuassist" auto-update="false" auto-delete="false" proxy="false">
      <foreignkey field-ref="dbdocume"/>
      </reference-descriptor>
      </class-descriptor>

      The problem seems to be with one of the two foreign keys (dbcodass), which is a VARCHAR.

      If I fill the dbcodass field with numeric values, everything works fine: I am able to retrieve a collection of Docassiste objects using getCollectionByQuery().

      The problem comes when I really use the dbcodass field as a VARCHAR field. As soon as I populate the table with alphanumeric values, nothing works anymore. getCollectionByQuery throws the following exception:

      QUERY BY CRITERIA _______ QueryByCriteria from class w4b.com.cassagest.db.Docassiste where [DBCODASS = PR1]
      java.lang.NumberFormatException: For input string: "PR1"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
      at java.lang.Integer.parseInt(Integer.java:468)
      at java.math.BigInteger.<init>(BigInteger.java:314)
      at java.math.BigInteger.<init>(BigInteger.java:447)
      at java.math.BigDecimal.<init>(BigDecimal.java:216)
      at org.postgresql.jdbc2.AbstractJdbc2Statement.numericValueOf(AbstractJdbc2Statement.java:1477)
      at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1520)
      at

      (full stacktrace below)

      NOTE: If I remove form <class-descriptor class="w4b.com.cassagest.db.Passiste" table="PASSISTE">:

      <reference-descriptor name="dbcodassRef" class-ref="w4b.com.cassagest.db.Passiste" auto-update="false" auto-delete="false" proxy="false">
      <foreignkey field-ref="dbcodass"/>
      </reference-descriptor>

      and this lines from NOTE: If I remove form <class-descriptor class="w4b.com.cassagest.db.Docassiste" table="DOCASSISTE">::

      <collection-descriptor name="docassisteList" element-class-ref="w4b.com.cassagest.db.Docassiste" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="dbcodass"/>
      </collection-descriptor>

      The method getCollectionByQuery() work fine!!

      Any ideas?

      Alessandro

      COMPLETE REPOSITORY:

      <class-descriptor class="w4b.com.cassagest.db.Passiste" table="PASSISTE">
      <field-descriptor name="pbprogre" primarykey="true" default-fetch="true" autoincrement="true" sequence-name="public.passiste_pbprogre_seq" column="PBPROGRE" jdbc-type="INTEGER"/>
      <field-descriptor name="pbcodass" nullable="false" default-fetch="true" column="PBCODASS" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbdtinval" default-fetch="true" column="PBDTINVAL" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbdtfival" default-fetch="true" column="PBDTFIVAL" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbdescri" default-fetch="true" column="PBDESCRI" jdbc-type="CHAR"/>
      <field-descriptor name="pbgglimd" default-fetch="true" column="PBGGLIMD" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbdtlimd" default-fetch="true" column="PBDTLIMD" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbdtlavf" default-fetch="true" column="PBDTLAVF" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbnumean" default-fetch="true" column="PBNUMEAN" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbfamili" default-fetch="true" column="PBFAMILI" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbachias" default-fetch="true" column="PBACHIAS" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbunicae" default-fetch="true" column="PBUNICAE" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbpercen" default-fetch="true" column="PBPERCEN" jdbc-type="NUMERIC"/>
      <field-descriptor name="pbricvot" default-fetch="true" column="PBRICVOT" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbimpoun" default-fetch="true" column="PBIMPOUN" jdbc-type="NUMERIC"/>
      <field-descriptor name="pbimpmax" default-fetch="true" column="PBIMPMAX" jdbc-type="NUMERIC"/>
      <field-descriptor name="pbvotoin" default-fetch="true" column="PBVOTOIN" jdbc-type="INTEGER"/>
      <field-descriptor name="pbvotofi" default-fetch="true" column="PBVOTOFI" jdbc-type="INTEGER"/>
      <field-descriptor name="pbricore" default-fetch="true" column="PBRICORE" jdbc-type="VARCHAR"/>
      <field-descriptor name="pblimore" default-fetch="true" column="PBLIMORE" jdbc-type="SMALLINT"/>
      <field-descriptor name="pboresim" default-fetch="true" column="PBORESIM" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbprogra" default-fetch="true" column="PBPROGRA" jdbc-type="CHAR"/>
      <field-descriptor name="pbrimimp" default-fetch="true" column="PBRIMIMP" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbetaini" default-fetch="true" column="PBETAINI" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbetafin" default-fetch="true" column="PBETAFIN" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbassstu" default-fetch="true" column="PBASSSTU" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbnuasdl" default-fetch="true" column="PBNUASDL" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbnuasll" default-fetch="true" column="PBNUASLL" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbdtinco" default-fetch="true" column="PBDTINCO" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbdtfico" default-fetch="true" column="PBDTFICO" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/>
      <field-descriptor name="pbconreg" default-fetch="true" column="PBCONREG" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbtidata" default-fetch="true" column="PBTIDATA" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbannota" default-fetch="true" column="PBANNOTA" jdbc-type="CHAR"/>
      <field-descriptor name="pbdescr1" default-fetch="true" column="PBDESCR1" jdbc-type="CHAR"/>
      <field-descriptor name="pbdescr2" default-fetch="true" column="PBDESCR2" jdbc-type="CHAR"/>
      <field-descriptor name="pbdescr3" default-fetch="true" column="PBDESCR3" jdbc-type="CHAR"/>
      <field-descriptor name="pbdescr4" default-fetch="true" column="PBDESCR4" jdbc-type="CHAR"/>
      <field-descriptor name="pbumisu1" default-fetch="true" column="PBUMISU1" jdbc-type="CHAR"/>
      <field-descriptor name="pbumisu2" default-fetch="true" column="PBUMISU2" jdbc-type="CHAR"/>
      <field-descriptor name="pbumisu3" default-fetch="true" column="PBUMISU3" jdbc-type="CHAR"/>
      <field-descriptor name="pbumisu4" default-fetch="true" column="PBUMISU4" jdbc-type="CHAR"/>
      <field-descriptor name="pbformul" default-fetch="true" column="PBFORMUL" jdbc-type="VARCHAR"/>
      <field-descriptor name="pbnummes" default-fetch="true" column="PBNUMMES" jdbc-type="SMALLINT"/>
      <field-descriptor name="pbtipolo" default-fetch="true" column="PBTIPOLO" jdbc-type="CHAR"/>
      <field-descriptor name="pbassfis" default-fetch="true" column="PBASSFIS" jdbc-type="SMALLINT"/>
      <collection-descriptor name="docassisteList" element-class-ref="w4b.com.cassagest.db.Docassiste" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="dbcodass"/>
      </collection-descriptor>
      <collection-descriptor name="regassisteList" element-class-ref="w4b.com.cassagest.db.Regassiste" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="rbcodass"/>
      </collection-descriptor>
      </class-descriptor>

      <class-descriptor class="w4b.com.cassagest.db.Docassiste" table="DOCASSISTE">
      <field-descriptor name="dbprogre" primarykey="true" default-fetch="true" autoincrement="true" sequence-name="public.docassiste_dbprogre_seq" column="DBPROGRE" jdbc-type="INTEGER"/>
      <field-descriptor name="dbcodass" default-fetch="true" column="DBCODASS" jdbc-type="VARCHAR"/>
      <field-descriptor name="dbdocume" default-fetch="true" column="DBDOCUME" jdbc-type="INTEGER"/>
      <field-descriptor name="dbobblig" default-fetch="true" column="DBOBBLIG" jdbc-type="VARCHAR"/>
      <field-descriptor name="dbannota" default-fetch="true" column="DBANNOTA" jdbc-type="CHAR"/>
      <reference-descriptor name="dbcodassRef" class-ref="w4b.com.cassagest.db.Passiste" auto-update="false" auto-delete="false" proxy="false">
      <foreignkey field-ref="dbcodass"/>
      </reference-descriptor>
      <reference-descriptor name="dbdocumeRef" class-ref="w4b.com.cassagest.db.Docuassist" auto-update="false" auto-delete="false" proxy="false">
      <foreignkey field-ref="dbdocume"/>
      </reference-descriptor>
      </class-descriptor>

      <class-descriptor class="w4b.com.cassagest.db.Docuassist" table="DOCUASSIST">
      <field-descriptor name="dgprogre" primarykey="true" default-fetch="true" autoincrement="true" sequence-name="public.docuassist_dgprogre_seq" column="DGPROGRE" jdbc-type="INTEGER"/>
      <field-descriptor name="dgdescri" default-fetch="true" column="DGDESCRI" jdbc-type="CHAR"/>
      <field-descriptor name="dgdescre" default-fetch="true" column="DGDESCRE" jdbc-type="VARCHAR"/>
      <collection-descriptor name="docassisteList" element-class-ref="w4b.com.cassagest.db.Docassiste" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="dbdocume"/>
      </collection-descriptor>
      <collection-descriptor name="docregassList" element-class-ref="w4b.com.cassagest.db.Docregass" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="dfdocume"/>
      </collection-descriptor>
      <collection-descriptor name="docassistsList" element-class-ref="w4b.com.cassagest.db.Docassists" auto-update="false" auto-delete="false" proxy="false" auto-retrieve="false">
      <inverse-foreignkey field-ref="dbdocume"/>
      </collection-descriptor>
      </class-descriptor>

      Attachments

        Activity

          People

            Unassigned Unassigned
            a.vincelli Alessandro Vincelli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: