db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian K. Wallace" <br...@transmorphix.com>
Subject Re: Problem with addAscendingOrderByColum
Date Tue, 03 Jun 2003 21:55:02 GMT

On 3 Jun 2003 at 13:16, Ryan Schutt wrote:

> You can't use alternate database names in criterias that use order by or group
> by.  This is a torque bug, AFAIK.  We've been bit by this one too.
> 
While I'll readily agree that this is a serious bug for utilizing Torque 
generated objects when dealing with a database other than the one 
for which the object was generated, there _is_ a workaround - but 
it's ugly. (At least to have to do it in application code) If you want to 
try it, here it is (and this assumes that all your connections are 
already defined and initialized for Torque):

  Register all the MapBuilder files you need to use outside of the 
database connection for which they were generated and call 
Torque.registerMapBuilder(full.mapbuilder.package.XXXMapBuilder
.class) for each one.
  Now that Torque has been instructed how to cope with all those 
'table maps', you can now take one of two approaces. What I've had 
to do is copy an entire database's worth of objects to another 
'connection' (an example follows). The other option is to simply copy 
a table (or set of tables) from its default connection to the 
connection you need.

  An example of copying an entire <code>DatabaseMap</code>:
    DatabaseMap orignalMap = 
Torque.getDatabaseMap(originatingConnection);
    DatabaseMap destinationMap = 
Torque.getDatabaseMap(destinationConnection);
    TableMap[] tables = originalMap.getTables();
    for (int i = 0; i < tables.length; i++) {
      destinationMap.addTable(tables);
    }

I'm 100% positive there's a different way to do it, but what's written 
above is actually in working code where we create an initial 
database to use as a template for n+1 databases (we have no idea 
how many the customer will end up creating from this template).

I said it was ugly - now you see why... but it does fix the NPE you get 
trying to use non-compiled-in connections.

Hope it helps.
> 
> --- Benoit Tramblay <benoit.tramblay@technomedia.ca> wrote:
> > Hello,
> >  
> > I Have created an Criteria object with a database name and i have used the
> > addAscendingOrderByColum method.
> > During execution, i have a null pointer Exception on BasesObject for
> > createQuery method.
> >  
> > When i removed the dabasename in criteria constructor, programm is running.
> >  
> > Do you know this problem ?
> > Thanks.
> >  
> >  
> > java.lang.NullPointerException
> >         at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1209)
> >         at
> > org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
> >         at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1321)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelectVi
> > llageRecords(BaseTqEntreprisePeer.java:450)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelectVi
> > llageRecords(BaseTqEntreprisePeer.java:417)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelect(B
> > aseTqEntreprisePeer.java:386)
> >         at
> > ca.technomedia.sigal.common.persistency.data.TqEntreprisePeer.getEntrepriseL
> > istByParentOrGroupId(TqEntreprisePeer.java:80)
> >         at
> > ca.technomedia.sigal.common.persistency.adapter.entreprise.EntrepriseAdapter
> > .loadbyParentOrGroupId(EntrepriseAdapter.java:65)
> >         at
> > ca.technomedia.sigal.common.model.entreprise.Entreprise.loadSubEntreprise(En
> > treprise.java:285)
> >         at
> > ca.technomedia.sigal.common.model.entreprise.facade.EntrepriseImpl.loadWithE
> > lements(EntrepriseImpl.java:53)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.process(TestEnterpriseLoad.java:52)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.<init>(TestEnterpriseLoad.java:35)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.main(TestEnterpriseLoad.java:68)
> > rethrown as org.apache.torque.TorqueException
> >         at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1334)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelectVi
> > llageRecords(BaseTqEntreprisePeer.java:450)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelectVi
> > llageRecords(BaseTqEntreprisePeer.java:417)
> >         at
> > ca.technomedia.sigal.common.persistency.data.BaseTqEntreprisePeer.doSelect(B
> > aseTqEntreprisePeer.java:386)
> >         at
> > ca.technomedia.sigal.common.persistency.data.TqEntreprisePeer.getEntrepriseL
> > istByParentOrGroupId(TqEntreprisePeer.java:80)
> >         at
> > ca.technomedia.sigal.common.persistency.adapter.entreprise.EntrepriseAdapter
> > .loadbyParentOrGroupId(EntrepriseAdapter.java:65)
> >         at
> > ca.technomedia.sigal.common.model.entreprise.Entreprise.loadSubEntreprise(En
> > treprise.java:285)
> >         at
> > ca.technomedia.sigal.common.model.entreprise.facade.EntrepriseImpl.loadWithE
> > lements(EntrepriseImpl.java:53)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.process(TestEnterpriseLoad.java:52)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.<init>(TestEnterpriseLoad.java:35)
> >         at
> > tests.model.BTY.TestEnterpriseLoad.main(TestEnterpriseLoad.java:68)
> > Caused by: java.lang.NullPointerException
> >         at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1209)
> >         at
> > org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
> >         at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1321)
> >         ... 10 more
> > 
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 



Mime
View raw message