You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by St...@zas.admin.ch on 2004/06/11 17:12:09 UTC

My proxies do not make late binding




Hello,

I have a problem : even if I define proxy for a connection, OJB reads the
linked objects immediately.

Explanation : I have a class Dossier, wich is the entry point of my
application. This class is mapped to a DB2 table called TMPDOSSIER. Each
dossier has a collection of Prestation. Prestation is an abstract class
with two concrete subclasses called Apg and IJ. Both are mapped to the same
table TMPPREST. The collection has proxy="true".

When I read an instance of Dossier and look the result with my debugger, I
can see that the collection is of type
org.apache.ojb.broker.accesslayer.ListProxy, but that all elements are
alraedy instatiated, even before I access Dossier from the result list of
the query.

I wonder : what am I doing wrong ?

Thnk you for the help

Stefano



I am working with RC6,  DB2 and JDK 1.4. Here are my query and my
repository.xml definition :

---------------------------------------------------------------------

Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("TESTDEV",Database.OPEN_READ_WRITE);
Transaction tx = odmg.newTransaction();
tx.begin();
OQLQuery q = odmg.newOQLQuery();
q.create("select dossiers from " + DossierImpl.class.getName() + " where id
= $1");
q.bind("test.ojb.1000");
DList result = (DList) q.execute();
Dossier d = (Dossier) result.iterator().next();

---------------------------------------------------------------------
      <class-descriptor
            class=
"ch.admin.formation.java.model.commun.test.impl.DossierImpl"
            table="TMPDOSSIER"
      >
            <field-descriptor
                  name="id"
                  column="ID"
                  jdbc-type="VARCHAR"
                  primarykey="true"
                  autoincrement="false"
            />
            <field-descriptor
            name="titulaireAVS"
            column="NO_AVS"
            jdbc-type="VARCHAR"
            conversion=
"ch.admin.ofit.test.ojb.conversion.NumeroAvs2SqlVarcharFiedConversion"
            />

            <collection-descriptor
                  name="prestations"
                  element-class-ref=
"ch.admin.formation.java.model.commun.test.impl.PrestationImpl"
                  proxy="true"
                  auto-update="object"
            >
                  <inverse-foreignkey field-ref="idDossier"/>
            </collection-descriptor>
      </class-descriptor>

      <class-descriptor
            class=
"ch.admin.formation.java.model.commun.test.impl.PrestationImpl"
      >
            <extent-class class-ref=
"ch.admin.formation.java.model.apg.test.impl.ApgImpl"/>
            <extent-class class-ref=
"ch.admin.formation.java.model.ij.test.impl.IJImpl"/>
      </class-descriptor>

      <class-descriptor
            class="ch.admin.formation.java.model.apg.test.impl.ApgImpl"
            table="TMPPREST"
      >
            <field-descriptor
                  name="id"
                  column="ID"
                  jdbc-type="VARCHAR"
                  primarykey="true"
                  autoincrement="false"
            />
                  <field-descriptor
                  name="montant"
                  column="MT_DEC"
                  jdbc-type="DECIMAL"
                  />
                  <field-descriptor
                  name="discriminant"
                  column="TYPE"
                  jdbc-type="CHAR"
                  />
                  <field-descriptor
                        name="idDossier"
                        jdbc-type="VARCHAR"
                        column="ID_DOSSIER"
                        access="anonymous"
                  />
                  <field-descriptor
                  name="ojbConcreteClass"
                        jdbc-type="VARCHAR"
                        column="CLASS_NAME"
                  />
      </class-descriptor>

      <class-descriptor
            class="ch.admin.formation.java.model.ij.test.impl.IJImpl"
            table="TMPPREST"
      >
            <field-descriptor
                  name="id"
                  column="ID"
                  jdbc-type="VARCHAR"
                  primarykey="true"
                  autoincrement="false"
            />
                  <field-descriptor
                  name="montant"
                        column="MT_DEC"
                        jdbc-type="DECIMAL"
                  />
                  <field-descriptor
                        name="discriminant"
                        column="TYPE"
                        jdbc-type="CHAR"
                  />
                  <field-descriptor
                  name="dateDebut"
                  column="I_DT_DEBUT"
                  jdbc-type="VARCHAR"
                  conversion=
"ch.admin.ofit.ojb.conversion.Date2SqlVarcharFiedConversion"
                  />
            <field-descriptor
                  name="dateFin"
                  column="I_DT_FIN"
                  jdbc-type="VARCHAR"
                  conversion=
"ch.admin.ofit.ojb.conversion.Date2SqlVarcharFiedConversion"
                  />
                  <field-descriptor
                        name="idDossier"
                        jdbc-type="VARCHAR"
                        column="ID_DOSSIER"
                        access="anonymous"
                  />
                  <field-descriptor
                        name="ojbConcreteClass"
                        jdbc-type="VARCHAR"
                        column="CLASS_NAME"
                  />
     </class-descriptor>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: My proxies do not make late binding

Posted by Thomas Dudziak <to...@first.fhg.de>.
On Fri, 11 Jun 2004 Stefano.Juri@zas.admin.ch wrote:

> I have a problem : even if I define proxy for a connection, OJB reads the
> linked objects immediately.
> 
> Explanation : I have a class Dossier, wich is the entry point of my
> application. This class is mapped to a DB2 table called TMPDOSSIER. Each
> dossier has a collection of Prestation. Prestation is an abstract class
> with two concrete subclasses called Apg and IJ. Both are mapped to the same
> table TMPPREST. The collection has proxy="true".
> 
> When I read an instance of Dossier and look the result with my debugger, I
> can see that the collection is of type
> org.apache.ojb.broker.accesslayer.ListProxy, but that all elements are
> alraedy instatiated, even before I access Dossier from the result list of
> the query.
> 
> I wonder : what am I doing wrong ?

The problem lies with the collection proxy right ? Well, I think that the
OJB version you're using does not support collection proxies for ODMG. You
should try CVS because I think Brian added a patch for that:

http://nagoya.apache.org/eyebrowse/ReadMsg?listName=ojb-dev@db.apache.org&msgNo=7497

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org