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 Alessandro Colantoni <ac...@brujulatelecom.com> on 2004/11/24 15:04:56 UTC

addPrefetchedRelationship problems

Hi all.!!
 
I have the following repository snip
 
<class-descriptor class="com.brujulatelecom.srv.vo.CupoBloqueadoVO"
                        table="T_SRV_CUPOBLOQUEADO"
isolation-level="optimistic">
            <field-descriptor id="1" name="cblCodigo"
column="CBL_CODIGO"
                  jdbc-type="INTEGER" primarykey="true"
autoincrement="false"
                  sequence-name="S_SRV_CBL"/>
    <field-descriptor id="2" name="cblSalCodigo" column="CBL_SALCODIGO"
                    jdbc-type="INTEGER" primarykey="true" />
    <field-descriptor id="3" name="cblOfiCodigo" column="CBL_OFICODIGO"
                    jdbc-type="INTEGER"/>

    <field-descriptor id="4" name="cblPlazas" column="CBL_PLAZAS"
                    jdbc-type="INTEGER"/>
    <field-descriptor id="5" name="cblServidor" column="CBL_SERVIDOR"
                    jdbc-type="VARCHAR"/>
    <field-descriptor id="6" name="cblDateCreated"
column="CBL_DATE_CREATED"
                    jdbc-type="TIMESTAMP"/>
    <field-descriptor id="7" name="cblDateModified"
column="CBL_DATE_MODIFIED"
                    jdbc-type="TIMESTAMP"/>
    <field-descriptor id="8" name="cblModifiedBy"
column="CBL_MODIFIED_BY"
                    jdbc-type="VARCHAR"/>
    <field-descriptor id="9" name="cblCreatedBy" column="CBL_CREATED_BY"
                    jdbc-type="VARCHAR"/>
    <field-descriptor id="10" name="cblBorrado" column="CBL_BORRADO"
                    jdbc-type="CHAR"/>
    <field-descriptor id="11" name="cblTemporada" column="CBL_TEMPORADA"
                    jdbc-type="INTEGER"/>
    <field-descriptor id="12" name="cblAckOptLock"
column="CBL_ACKOPTLOCK"
                    jdbc-type="INTEGER"
                    locking="true"/>
    <field-descriptor id="13" name="cblEreCodigo" column="CBL_ERECODIGO"
                    jdbc-type="INTEGER"/>
    <reference-descriptor name="salidaVO"
                    class-ref="com.brujulatelecom.srv.vo.SalidaVO"
                    auto-retrieve="false">                   
      <foreignkey field-ref="cblSalCodigo"/>
    </reference-descriptor>
    <reference-descriptor name="oficinaVO"
                    class-ref="com.brujulatelecom.srv.vo.OficinaVO"
                    auto-retrieve="false">                   
      <foreignkey field-ref="cblOfiCodigo"/>
    </reference-descriptor>
</class-descriptor>
 
and I have the following method in my Dao
 
 
public ValueObject findByPrimaryKey(String cblCodigo, String
cblSalCodigo)throws DataAccessException{
        log.info("************Entering the
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo)***************");
        PersistenceBroker broker = null;
        CupoBloqueadoVO cupoBloqueadoVO = null;
        try{   
            Criteria criteria = new Criteria();
            
 
criteria.addEqualTo("cblTemporada",ServiceParametro.getInstance().getVal
TemporadaActual());
            
            //criteria.addEqualTo("cblBorrado","N");
            criteria.addEqualTo("cblCodigo",new Integer(cblCodigo));
            criteria.addEqualTo("cblSalCodigo",new
Integer(cblSalCodigo));
            broker = ServiceLocator.getInstance().findBroker();
            //QueryByCriteria query = new
QueryByCriteria(CupoBloqueadoVO.class, criteria);
            QueryByCriteria query =
QueryFactory.newQuery(CupoBloqueadoVO.class, criteria);
            query.addPrefetchedRelationship("salidaVO");
            query.addPrefetchedRelationship("oficinaVO");
            cupoBloqueadoVO =
(CupoBloqueadoVO)broker.getObjectByQuery(query);            
            
        } catch (ServiceParametroException e){
            log.error("ServiceParametroException thrown in
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo): " + e.toString());
            throw new DataAccessException("Error in
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo): " + e.toString(),e);
        }catch (ServiceLocatorException e) {
            log.error("ServiceLocatorException thrown in
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo): " + e.toString());
            throw new DataAccessException("Error in
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo): " + e.toString(),e);
        } finally {
                  if (broker != null) broker.close();
        }
        log.info("************Done with the
CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
cblSalCodigo)***************");
        return cupoBloqueadoVO;
    }   
 
 
 
The cipoBloquadoVO I return has oficinaVO and salidaVO empties!!
 
Where I am wrong??
 
Every suggestion will be helpful.. thanks in advance
 
 

RE: addPrefetchedRelationship problems

Posted by Alessandro Colantoni <ac...@brujulatelecom.com>.
Yes I've done yet and it Works.
Cheers!


-----Mensaje original-----
De: Daniel Perry [mailto:d.perry@netcase.co.uk] 
Enviado el: miércoles, 24 de noviembre de 2004 16:00
Para: OJB Users List
Asunto: RE: addPrefetchedRelationship problems

Ok, my bad! I hadnt payed enough attention to the title :)

I've never used the addPrefetchedRelationship method, as i tend to just
use
auto-retrieve=true.  I cant find any documentation on it. retrieve=true
should work (for now at least).

Can anyone comment on how the addPrefetchedRelationship method works?

Daniel.

> -----Original Message-----
> From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> Sent: 24 November 2004 14:40
> To: 'OJB Users List'
> Subject: RE: addPrefetchedRelationship problems
>
>
> Thanks for the rapid answer( just the time to eat something !!! :--))
> I had understood that the addPrefetchedRelationship was an alternative
> to the autoretrieve = true.
> But probably is just a way to optimize it
>
> I get the opportunity, seen the polemic on the forum, to say that
every
> time I asked for something of ojb always someone answered me very soon
,
> as in this case , for very complicate thinks too.
> So I have to thanks all are involved in this work that is great
> Hasta luego
>
> -----Mensaje original-----
> De: Daniel Perry [mailto:d.perry@netcase.co.uk]
> Enviado el: miércoles, 24 de noviembre de 2004 15:09
> Para: OJB Users List
> Asunto: RE: addPrefetchedRelationship problems
>
> I believe this is because you have auto-retrieve="false" in the
> reference
> descriptors.  If you set these to true, the objects will be loaded.
>
> Daniel.
>
> > -----Original Message-----
> > From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> > Sent: 24 November 2004 14:05
> > To: 'OJB Users List'
> > Subject: addPrefetchedRelationship problems
> >
> >
> > Hi all.!!
> >
> > I have the following repository snip
> >
> > <class-descriptor class="com.brujulatelecom.srv.vo.CupoBloqueadoVO"
> >                         table="T_SRV_CUPOBLOQUEADO"
> > isolation-level="optimistic">
> >             <field-descriptor id="1" name="cblCodigo"
> > column="CBL_CODIGO"
> >                   jdbc-type="INTEGER" primarykey="true"
> > autoincrement="false"
> >                   sequence-name="S_SRV_CBL"/>
> >     <field-descriptor id="2" name="cblSalCodigo"
> column="CBL_SALCODIGO"
> >                     jdbc-type="INTEGER" primarykey="true" />
> >     <field-descriptor id="3" name="cblOfiCodigo"
> column="CBL_OFICODIGO"
> >                     jdbc-type="INTEGER"/>
> >
> >     <field-descriptor id="4" name="cblPlazas" column="CBL_PLAZAS"
> >                     jdbc-type="INTEGER"/>
> >     <field-descriptor id="5" name="cblServidor"
column="CBL_SERVIDOR"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="6" name="cblDateCreated"
> > column="CBL_DATE_CREATED"
> >                     jdbc-type="TIMESTAMP"/>
> >     <field-descriptor id="7" name="cblDateModified"
> > column="CBL_DATE_MODIFIED"
> >                     jdbc-type="TIMESTAMP"/>
> >     <field-descriptor id="8" name="cblModifiedBy"
> > column="CBL_MODIFIED_BY"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="9" name="cblCreatedBy"
> column="CBL_CREATED_BY"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="10" name="cblBorrado" column="CBL_BORRADO"
> >                     jdbc-type="CHAR"/>
> >     <field-descriptor id="11" name="cblTemporada"
> column="CBL_TEMPORADA"
> >                     jdbc-type="INTEGER"/>
> >     <field-descriptor id="12" name="cblAckOptLock"
> > column="CBL_ACKOPTLOCK"
> >                     jdbc-type="INTEGER"
> >                     locking="true"/>
> >     <field-descriptor id="13" name="cblEreCodigo"
> column="CBL_ERECODIGO"
> >                     jdbc-type="INTEGER"/>
> >     <reference-descriptor name="salidaVO"
> >                     class-ref="com.brujulatelecom.srv.vo.SalidaVO"
> >                     auto-retrieve="false">
> >       <foreignkey field-ref="cblSalCodigo"/>
> >     </reference-descriptor>
> >     <reference-descriptor name="oficinaVO"
> >                     class-ref="com.brujulatelecom.srv.vo.OficinaVO"
> >                     auto-retrieve="false">
> >       <foreignkey field-ref="cblOfiCodigo"/>
> >     </reference-descriptor>
> > </class-descriptor>
> >
> > and I have the following method in my Dao
> >
> >
> > public ValueObject findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)throws DataAccessException{
> >         log.info("************Entering the
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)***************");
> >         PersistenceBroker broker = null;
> >         CupoBloqueadoVO cupoBloqueadoVO = null;
> >         try{
> >             Criteria criteria = new Criteria();
> >
> >
> >
>
criteria.addEqualTo("cblTemporada",ServiceParametro.getInstance().getVal
> > TemporadaActual());
> >
> >             //criteria.addEqualTo("cblBorrado","N");
> >             criteria.addEqualTo("cblCodigo",new Integer(cblCodigo));
> >             criteria.addEqualTo("cblSalCodigo",new
> > Integer(cblSalCodigo));
> >             broker = ServiceLocator.getInstance().findBroker();
> >             //QueryByCriteria query = new
> > QueryByCriteria(CupoBloqueadoVO.class, criteria);
> >             QueryByCriteria query =
> > QueryFactory.newQuery(CupoBloqueadoVO.class, criteria);
> >             query.addPrefetchedRelationship("salidaVO");
> >             query.addPrefetchedRelationship("oficinaVO");
> >             cupoBloqueadoVO =
> > (CupoBloqueadoVO)broker.getObjectByQuery(query);
> >
> >         } catch (ServiceParametroException e){
> >             log.error("ServiceParametroException thrown in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString());
> >             throw new DataAccessException("Error in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString(),e);
> >         }catch (ServiceLocatorException e) {
> >             log.error("ServiceLocatorException thrown in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString());
> >             throw new DataAccessException("Error in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString(),e);
> >         } finally {
> >                   if (broker != null) broker.close();
> >         }
> >         log.info("************Done with the
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)***************");
> >         return cupoBloqueadoVO;
> >     }
> >
> >
> >
> > The cipoBloquadoVO I return has oficinaVO and salidaVO empties!!
> >
> > Where I am wrong??
> >
> > Every suggestion will be helpful.. thanks in advance
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


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




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


RE: addPrefetchedRelationship problems

Posted by Daniel Perry <d....@netcase.co.uk>.
Ok, my bad! I hadnt payed enough attention to the title :)

I've never used the addPrefetchedRelationship method, as i tend to just use
auto-retrieve=true.  I cant find any documentation on it. retrieve=true
should work (for now at least).

Can anyone comment on how the addPrefetchedRelationship method works?

Daniel.

> -----Original Message-----
> From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> Sent: 24 November 2004 14:40
> To: 'OJB Users List'
> Subject: RE: addPrefetchedRelationship problems
>
>
> Thanks for the rapid answer( just the time to eat something !!! :--))
> I had understood that the addPrefetchedRelationship was an alternative
> to the autoretrieve = true.
> But probably is just a way to optimize it
>
> I get the opportunity, seen the polemic on the forum, to say that every
> time I asked for something of ojb always someone answered me very soon ,
> as in this case , for very complicate thinks too.
> So I have to thanks all are involved in this work that is great
> Hasta luego
>
> -----Mensaje original-----
> De: Daniel Perry [mailto:d.perry@netcase.co.uk]
> Enviado el: miércoles, 24 de noviembre de 2004 15:09
> Para: OJB Users List
> Asunto: RE: addPrefetchedRelationship problems
>
> I believe this is because you have auto-retrieve="false" in the
> reference
> descriptors.  If you set these to true, the objects will be loaded.
>
> Daniel.
>
> > -----Original Message-----
> > From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> > Sent: 24 November 2004 14:05
> > To: 'OJB Users List'
> > Subject: addPrefetchedRelationship problems
> >
> >
> > Hi all.!!
> >
> > I have the following repository snip
> >
> > <class-descriptor class="com.brujulatelecom.srv.vo.CupoBloqueadoVO"
> >                         table="T_SRV_CUPOBLOQUEADO"
> > isolation-level="optimistic">
> >             <field-descriptor id="1" name="cblCodigo"
> > column="CBL_CODIGO"
> >                   jdbc-type="INTEGER" primarykey="true"
> > autoincrement="false"
> >                   sequence-name="S_SRV_CBL"/>
> >     <field-descriptor id="2" name="cblSalCodigo"
> column="CBL_SALCODIGO"
> >                     jdbc-type="INTEGER" primarykey="true" />
> >     <field-descriptor id="3" name="cblOfiCodigo"
> column="CBL_OFICODIGO"
> >                     jdbc-type="INTEGER"/>
> >
> >     <field-descriptor id="4" name="cblPlazas" column="CBL_PLAZAS"
> >                     jdbc-type="INTEGER"/>
> >     <field-descriptor id="5" name="cblServidor" column="CBL_SERVIDOR"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="6" name="cblDateCreated"
> > column="CBL_DATE_CREATED"
> >                     jdbc-type="TIMESTAMP"/>
> >     <field-descriptor id="7" name="cblDateModified"
> > column="CBL_DATE_MODIFIED"
> >                     jdbc-type="TIMESTAMP"/>
> >     <field-descriptor id="8" name="cblModifiedBy"
> > column="CBL_MODIFIED_BY"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="9" name="cblCreatedBy"
> column="CBL_CREATED_BY"
> >                     jdbc-type="VARCHAR"/>
> >     <field-descriptor id="10" name="cblBorrado" column="CBL_BORRADO"
> >                     jdbc-type="CHAR"/>
> >     <field-descriptor id="11" name="cblTemporada"
> column="CBL_TEMPORADA"
> >                     jdbc-type="INTEGER"/>
> >     <field-descriptor id="12" name="cblAckOptLock"
> > column="CBL_ACKOPTLOCK"
> >                     jdbc-type="INTEGER"
> >                     locking="true"/>
> >     <field-descriptor id="13" name="cblEreCodigo"
> column="CBL_ERECODIGO"
> >                     jdbc-type="INTEGER"/>
> >     <reference-descriptor name="salidaVO"
> >                     class-ref="com.brujulatelecom.srv.vo.SalidaVO"
> >                     auto-retrieve="false">
> >       <foreignkey field-ref="cblSalCodigo"/>
> >     </reference-descriptor>
> >     <reference-descriptor name="oficinaVO"
> >                     class-ref="com.brujulatelecom.srv.vo.OficinaVO"
> >                     auto-retrieve="false">
> >       <foreignkey field-ref="cblOfiCodigo"/>
> >     </reference-descriptor>
> > </class-descriptor>
> >
> > and I have the following method in my Dao
> >
> >
> > public ValueObject findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)throws DataAccessException{
> >         log.info("************Entering the
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)***************");
> >         PersistenceBroker broker = null;
> >         CupoBloqueadoVO cupoBloqueadoVO = null;
> >         try{
> >             Criteria criteria = new Criteria();
> >
> >
> >
> criteria.addEqualTo("cblTemporada",ServiceParametro.getInstance().getVal
> > TemporadaActual());
> >
> >             //criteria.addEqualTo("cblBorrado","N");
> >             criteria.addEqualTo("cblCodigo",new Integer(cblCodigo));
> >             criteria.addEqualTo("cblSalCodigo",new
> > Integer(cblSalCodigo));
> >             broker = ServiceLocator.getInstance().findBroker();
> >             //QueryByCriteria query = new
> > QueryByCriteria(CupoBloqueadoVO.class, criteria);
> >             QueryByCriteria query =
> > QueryFactory.newQuery(CupoBloqueadoVO.class, criteria);
> >             query.addPrefetchedRelationship("salidaVO");
> >             query.addPrefetchedRelationship("oficinaVO");
> >             cupoBloqueadoVO =
> > (CupoBloqueadoVO)broker.getObjectByQuery(query);
> >
> >         } catch (ServiceParametroException e){
> >             log.error("ServiceParametroException thrown in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString());
> >             throw new DataAccessException("Error in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString(),e);
> >         }catch (ServiceLocatorException e) {
> >             log.error("ServiceLocatorException thrown in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString());
> >             throw new DataAccessException("Error in
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo): " + e.toString(),e);
> >         } finally {
> >                   if (broker != null) broker.close();
> >         }
> >         log.info("************Done with the
> > CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> > cblSalCodigo)***************");
> >         return cupoBloqueadoVO;
> >     }
> >
> >
> >
> > The cipoBloquadoVO I return has oficinaVO and salidaVO empties!!
> >
> > Where I am wrong??
> >
> > Every suggestion will be helpful.. thanks in advance
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


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


RE: addPrefetchedRelationship problems

Posted by Alessandro Colantoni <ac...@brujulatelecom.com>.
Thanks for the rapid answer( just the time to eat something !!! :--))
I had understood that the addPrefetchedRelationship was an alternative
to the autoretrieve = true.
But probably is just a way to optimize it

I get the opportunity, seen the polemic on the forum, to say that every
time I asked for something of ojb always someone answered me very soon ,
as in this case , for very complicate thinks too.
So I have to thanks all are involved in this work that is great
Hasta luego

-----Mensaje original-----
De: Daniel Perry [mailto:d.perry@netcase.co.uk] 
Enviado el: miércoles, 24 de noviembre de 2004 15:09
Para: OJB Users List
Asunto: RE: addPrefetchedRelationship problems

I believe this is because you have auto-retrieve="false" in the
reference
descriptors.  If you set these to true, the objects will be loaded.

Daniel.

> -----Original Message-----
> From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> Sent: 24 November 2004 14:05
> To: 'OJB Users List'
> Subject: addPrefetchedRelationship problems
>
>
> Hi all.!!
>
> I have the following repository snip
>
> <class-descriptor class="com.brujulatelecom.srv.vo.CupoBloqueadoVO"
>                         table="T_SRV_CUPOBLOQUEADO"
> isolation-level="optimistic">
>             <field-descriptor id="1" name="cblCodigo"
> column="CBL_CODIGO"
>                   jdbc-type="INTEGER" primarykey="true"
> autoincrement="false"
>                   sequence-name="S_SRV_CBL"/>
>     <field-descriptor id="2" name="cblSalCodigo"
column="CBL_SALCODIGO"
>                     jdbc-type="INTEGER" primarykey="true" />
>     <field-descriptor id="3" name="cblOfiCodigo"
column="CBL_OFICODIGO"
>                     jdbc-type="INTEGER"/>
>
>     <field-descriptor id="4" name="cblPlazas" column="CBL_PLAZAS"
>                     jdbc-type="INTEGER"/>
>     <field-descriptor id="5" name="cblServidor" column="CBL_SERVIDOR"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="6" name="cblDateCreated"
> column="CBL_DATE_CREATED"
>                     jdbc-type="TIMESTAMP"/>
>     <field-descriptor id="7" name="cblDateModified"
> column="CBL_DATE_MODIFIED"
>                     jdbc-type="TIMESTAMP"/>
>     <field-descriptor id="8" name="cblModifiedBy"
> column="CBL_MODIFIED_BY"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="9" name="cblCreatedBy"
column="CBL_CREATED_BY"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="10" name="cblBorrado" column="CBL_BORRADO"
>                     jdbc-type="CHAR"/>
>     <field-descriptor id="11" name="cblTemporada"
column="CBL_TEMPORADA"
>                     jdbc-type="INTEGER"/>
>     <field-descriptor id="12" name="cblAckOptLock"
> column="CBL_ACKOPTLOCK"
>                     jdbc-type="INTEGER"
>                     locking="true"/>
>     <field-descriptor id="13" name="cblEreCodigo"
column="CBL_ERECODIGO"
>                     jdbc-type="INTEGER"/>
>     <reference-descriptor name="salidaVO"
>                     class-ref="com.brujulatelecom.srv.vo.SalidaVO"
>                     auto-retrieve="false">
>       <foreignkey field-ref="cblSalCodigo"/>
>     </reference-descriptor>
>     <reference-descriptor name="oficinaVO"
>                     class-ref="com.brujulatelecom.srv.vo.OficinaVO"
>                     auto-retrieve="false">
>       <foreignkey field-ref="cblOfiCodigo"/>
>     </reference-descriptor>
> </class-descriptor>
>
> and I have the following method in my Dao
>
>
> public ValueObject findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)throws DataAccessException{
>         log.info("************Entering the
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)***************");
>         PersistenceBroker broker = null;
>         CupoBloqueadoVO cupoBloqueadoVO = null;
>         try{
>             Criteria criteria = new Criteria();
>
>
>
criteria.addEqualTo("cblTemporada",ServiceParametro.getInstance().getVal
> TemporadaActual());
>
>             //criteria.addEqualTo("cblBorrado","N");
>             criteria.addEqualTo("cblCodigo",new Integer(cblCodigo));
>             criteria.addEqualTo("cblSalCodigo",new
> Integer(cblSalCodigo));
>             broker = ServiceLocator.getInstance().findBroker();
>             //QueryByCriteria query = new
> QueryByCriteria(CupoBloqueadoVO.class, criteria);
>             QueryByCriteria query =
> QueryFactory.newQuery(CupoBloqueadoVO.class, criteria);
>             query.addPrefetchedRelationship("salidaVO");
>             query.addPrefetchedRelationship("oficinaVO");
>             cupoBloqueadoVO =
> (CupoBloqueadoVO)broker.getObjectByQuery(query);
>
>         } catch (ServiceParametroException e){
>             log.error("ServiceParametroException thrown in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString());
>             throw new DataAccessException("Error in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString(),e);
>         }catch (ServiceLocatorException e) {
>             log.error("ServiceLocatorException thrown in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString());
>             throw new DataAccessException("Error in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString(),e);
>         } finally {
>                   if (broker != null) broker.close();
>         }
>         log.info("************Done with the
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)***************");
>         return cupoBloqueadoVO;
>     }
>
>
>
> The cipoBloquadoVO I return has oficinaVO and salidaVO empties!!
>
> Where I am wrong??
>
> Every suggestion will be helpful.. thanks in advance
>
>
>


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




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


RE: addPrefetchedRelationship problems

Posted by Daniel Perry <d....@netcase.co.uk>.
I believe this is because you have auto-retrieve="false" in the reference
descriptors.  If you set these to true, the objects will be loaded.

Daniel.

> -----Original Message-----
> From: Alessandro Colantoni [mailto:acolantoni@brujulatelecom.com]
> Sent: 24 November 2004 14:05
> To: 'OJB Users List'
> Subject: addPrefetchedRelationship problems
>
>
> Hi all.!!
>
> I have the following repository snip
>
> <class-descriptor class="com.brujulatelecom.srv.vo.CupoBloqueadoVO"
>                         table="T_SRV_CUPOBLOQUEADO"
> isolation-level="optimistic">
>             <field-descriptor id="1" name="cblCodigo"
> column="CBL_CODIGO"
>                   jdbc-type="INTEGER" primarykey="true"
> autoincrement="false"
>                   sequence-name="S_SRV_CBL"/>
>     <field-descriptor id="2" name="cblSalCodigo" column="CBL_SALCODIGO"
>                     jdbc-type="INTEGER" primarykey="true" />
>     <field-descriptor id="3" name="cblOfiCodigo" column="CBL_OFICODIGO"
>                     jdbc-type="INTEGER"/>
>
>     <field-descriptor id="4" name="cblPlazas" column="CBL_PLAZAS"
>                     jdbc-type="INTEGER"/>
>     <field-descriptor id="5" name="cblServidor" column="CBL_SERVIDOR"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="6" name="cblDateCreated"
> column="CBL_DATE_CREATED"
>                     jdbc-type="TIMESTAMP"/>
>     <field-descriptor id="7" name="cblDateModified"
> column="CBL_DATE_MODIFIED"
>                     jdbc-type="TIMESTAMP"/>
>     <field-descriptor id="8" name="cblModifiedBy"
> column="CBL_MODIFIED_BY"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="9" name="cblCreatedBy" column="CBL_CREATED_BY"
>                     jdbc-type="VARCHAR"/>
>     <field-descriptor id="10" name="cblBorrado" column="CBL_BORRADO"
>                     jdbc-type="CHAR"/>
>     <field-descriptor id="11" name="cblTemporada" column="CBL_TEMPORADA"
>                     jdbc-type="INTEGER"/>
>     <field-descriptor id="12" name="cblAckOptLock"
> column="CBL_ACKOPTLOCK"
>                     jdbc-type="INTEGER"
>                     locking="true"/>
>     <field-descriptor id="13" name="cblEreCodigo" column="CBL_ERECODIGO"
>                     jdbc-type="INTEGER"/>
>     <reference-descriptor name="salidaVO"
>                     class-ref="com.brujulatelecom.srv.vo.SalidaVO"
>                     auto-retrieve="false">
>       <foreignkey field-ref="cblSalCodigo"/>
>     </reference-descriptor>
>     <reference-descriptor name="oficinaVO"
>                     class-ref="com.brujulatelecom.srv.vo.OficinaVO"
>                     auto-retrieve="false">
>       <foreignkey field-ref="cblOfiCodigo"/>
>     </reference-descriptor>
> </class-descriptor>
>
> and I have the following method in my Dao
>
>
> public ValueObject findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)throws DataAccessException{
>         log.info("************Entering the
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)***************");
>         PersistenceBroker broker = null;
>         CupoBloqueadoVO cupoBloqueadoVO = null;
>         try{
>             Criteria criteria = new Criteria();
>
>
> criteria.addEqualTo("cblTemporada",ServiceParametro.getInstance().getVal
> TemporadaActual());
>
>             //criteria.addEqualTo("cblBorrado","N");
>             criteria.addEqualTo("cblCodigo",new Integer(cblCodigo));
>             criteria.addEqualTo("cblSalCodigo",new
> Integer(cblSalCodigo));
>             broker = ServiceLocator.getInstance().findBroker();
>             //QueryByCriteria query = new
> QueryByCriteria(CupoBloqueadoVO.class, criteria);
>             QueryByCriteria query =
> QueryFactory.newQuery(CupoBloqueadoVO.class, criteria);
>             query.addPrefetchedRelationship("salidaVO");
>             query.addPrefetchedRelationship("oficinaVO");
>             cupoBloqueadoVO =
> (CupoBloqueadoVO)broker.getObjectByQuery(query);
>
>         } catch (ServiceParametroException e){
>             log.error("ServiceParametroException thrown in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString());
>             throw new DataAccessException("Error in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString(),e);
>         }catch (ServiceLocatorException e) {
>             log.error("ServiceLocatorException thrown in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString());
>             throw new DataAccessException("Error in
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo): " + e.toString(),e);
>         } finally {
>                   if (broker != null) broker.close();
>         }
>         log.info("************Done with the
> CupoBloqueadoDAO.findByPrimaryKey(String cblCodigo, String
> cblSalCodigo)***************");
>         return cupoBloqueadoVO;
>     }
>
>
>
> The cipoBloquadoVO I return has oficinaVO and salidaVO empties!!
>
> Where I am wrong??
>
> Every suggestion will be helpful.. thanks in advance
>
>
>


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