You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Gary Shea <sh...@gtsdesign.com> on 2003/10/30 04:26:41 UTC
DatabaseMap empty except for ID_TABLE?
I'm trying to track down a problem. I've been using Torque naively but
successfully for the last couple of months, but my first attempt to get
a little fancy has not been successful.
I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
and running into a NPE at the line:
ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
The application is using two databases ("rc4" and "summary"); at the
point of the NPE I have already successfully SELECTed from both and INSERTed
into "summary". I tried the following test code (basically the
beginning of doUpdate()):
DB db = Torque.getDB(poolName);
DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
_logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
String dbMapName = dbMap.getName();
_logger.debug("dbMapName: " + dbMapName);
TableMap[] tableMaps = dbMap.getTables();
for (int i = 0; i < tableMaps.length; ++i) {
_logger.debug(i + ": " + tableMaps[i].getName());
}
TableMap tableMap = dbMap.getTable(poolTable);
_logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
For poolName set to either "rc4" or "summary", the only tableMap found
is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
returns null, hence the NPE in the Torque code.
Any hints?
Regards,
Gary
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: DatabaseMap empty except for ID_TABLE?
Posted by Gary Shea <sh...@gtsdesign.com>.
Hi Henning --
Whoops, I was unclear. Sorry about that...
I want to use hsql in it's in-memory mode for unit testing, for maximum
performance. The schema is well-known and Torque classes already exist
for it. The downside of using an in-memory database is that the schema
must be built from scratch every time the tests are run. Torque is able
to create the schema for me in hsql, but it will build the _entire_
schema, hundreds of tables. The unit tests only apply to a few of the
tables. I want to create individual tables on demand. I have looked at
how to do it, but not recently -- it seemed like a pretty big
job. Just wondering if your changes would make it any easier...
Thanks!
Gary
[2003-11-04 11:16 +0100] Henning Schmiedehausen (hps@intermeta.de) wrote:
> Hi,
>
> the problem is, that the Torque peer and object classes are not
> configured from a generic class but built from templates and then have
> to be compiled. Dynamic building would be possible but you would have to
> generate the templates in memory, then run the compile on them and load
> the result with a class loader. Quite some work. :-)
>
> Unfortunately, Torque is best suited for well defined peers and objects
> which are built at compile time, not run time. If you want to build
> something with hsql for testing, why not use the actual peer and object
> classes but have a different Torque configuration for testing which uses
> hsql (I assume that you use a different database for production).
>
> Regards
> Henning
>
>
> On Mon, 2003-11-03 at 20:40, Gary Shea wrote:
> > Hi Henning --
> >
> > Thanks for the pointer. I was stuck on something much simpler than
> > the relatively sophisticated problem you described.
> >
> > I read your post about the collection of changes you posted a week or
> > two ago. I was wondering... I've been looking for a way to build
> > bits of a database schema (in hsql, with memory model) on the fly for unit
> > testing. I have not found a good tool for doing it. Torque knows
> > how, but is oriented towards a batch mode where it builds the entire db
> > schema at once. I haven't tried modifying it yet, but wondered if your
> > changes make that code more modular.
> >
> > Gary
> >
> > [2003-10-30 15:23 -0000] Henning P. Schmiedehausen (hps@intermeta.de) wrote:
> >
> > > Gary Shea <sh...@gtsdesign.com> writes:
> > >
> > > >I'm trying to track down a problem. I've been using Torque naively but
> > > >successfully for the last couple of months, but my first attempt to get
> > > >a little fancy has not been successful.
> > >
> > > As the table peers are static, you must access the peers first, before
> > > they get added to the dbMap.
> > >
> > > Try
> > >
> > > String dummy = RC4Peer.TABLE_NAME + SummaryPeer.TABLE_NAME;
> > >
> > > and then do it again. Better yet, lobby for my proposal. ;-)
> > >
> > > Regards
> > > Henning
> > >
> > >
> > > >I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
> > > >and running into a NPE at the line:
> > > > ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
> > >
> > > >The application is using two databases ("rc4" and "summary"); at the
> > > >point of the NPE I have already successfully SELECTed from both and INSERTed
> > > >into "summary". I tried the following test code (basically the
> > > >beginning of doUpdate()):
> > >
> > > > DB db = Torque.getDB(poolName);
> > > > DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
> > > > _logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
> > >
> > > > String dbMapName = dbMap.getName();
> > > > _logger.debug("dbMapName: " + dbMapName);
> > >
> > > > TableMap[] tableMaps = dbMap.getTables();
> > > > for (int i = 0; i < tableMaps.length; ++i) {
> > > > _logger.debug(i + ": " + tableMaps[i].getName());
> > > > }
> > > > TableMap tableMap = dbMap.getTable(poolTable);
> > > > _logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
> > >
> > > >For poolName set to either "rc4" or "summary", the only tableMap found
> > > >is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
> > > >returns null, hence the NPE in the Torque code.
> > >
> > > >Any hints?
> > >
> > > >Regards,
> > >
> > > > Gary
> > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> > > >For additional commands, e-mail: torque-dev-help@db.apache.org
> > >
> > > --
> > > Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> > > hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
> > >
> > > Java, perl, Solaris, Linux, xSP Consulting, Web Services
> > > freelance consultant -- Jakarta Turbine Development -- hero for hire
> > >
> > > "Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
> > > -- AOL CD when played backwards (User Friendly - 200-10-15)
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> > > For additional commands, e-mail: torque-dev-help@db.apache.org
> > >
> > >
> > >
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
>
> Java, perl, Solaris, Linux, xSP Consulting, Web Services
> freelance consultant -- Jakarta Turbine Development -- hero for hire
>
> "Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
> -- AOL CD when played backwards (User Friendly - 200-10-15)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: DatabaseMap empty except for ID_TABLE?
Posted by Henning Schmiedehausen <hp...@intermeta.de>.
Hi,
the problem is, that the Torque peer and object classes are not
configured from a generic class but built from templates and then have
to be compiled. Dynamic building would be possible but you would have to
generate the templates in memory, then run the compile on them and load
the result with a class loader. Quite some work. :-)
Unfortunately, Torque is best suited for well defined peers and objects
which are built at compile time, not run time. If you want to build
something with hsql for testing, why not use the actual peer and object
classes but have a different Torque configuration for testing which uses
hsql (I assume that you use a different database for production).
Regards
Henning
On Mon, 2003-11-03 at 20:40, Gary Shea wrote:
> Hi Henning --
>
> Thanks for the pointer. I was stuck on something much simpler than
> the relatively sophisticated problem you described.
>
> I read your post about the collection of changes you posted a week or
> two ago. I was wondering... I've been looking for a way to build
> bits of a database schema (in hsql, with memory model) on the fly for unit
> testing. I have not found a good tool for doing it. Torque knows
> how, but is oriented towards a batch mode where it builds the entire db
> schema at once. I haven't tried modifying it yet, but wondered if your
> changes make that code more modular.
>
> Gary
>
> [2003-10-30 15:23 -0000] Henning P. Schmiedehausen (hps@intermeta.de) wrote:
>
> > Gary Shea <sh...@gtsdesign.com> writes:
> >
> > >I'm trying to track down a problem. I've been using Torque naively but
> > >successfully for the last couple of months, but my first attempt to get
> > >a little fancy has not been successful.
> >
> > As the table peers are static, you must access the peers first, before
> > they get added to the dbMap.
> >
> > Try
> >
> > String dummy = RC4Peer.TABLE_NAME + SummaryPeer.TABLE_NAME;
> >
> > and then do it again. Better yet, lobby for my proposal. ;-)
> >
> > Regards
> > Henning
> >
> >
> > >I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
> > >and running into a NPE at the line:
> > > ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
> >
> > >The application is using two databases ("rc4" and "summary"); at the
> > >point of the NPE I have already successfully SELECTed from both and INSERTed
> > >into "summary". I tried the following test code (basically the
> > >beginning of doUpdate()):
> >
> > > DB db = Torque.getDB(poolName);
> > > DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
> > > _logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
> >
> > > String dbMapName = dbMap.getName();
> > > _logger.debug("dbMapName: " + dbMapName);
> >
> > > TableMap[] tableMaps = dbMap.getTables();
> > > for (int i = 0; i < tableMaps.length; ++i) {
> > > _logger.debug(i + ": " + tableMaps[i].getName());
> > > }
> > > TableMap tableMap = dbMap.getTable(poolTable);
> > > _logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
> >
> > >For poolName set to either "rc4" or "summary", the only tableMap found
> > >is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
> > >returns null, hence the NPE in the Torque code.
> >
> > >Any hints?
> >
> > >Regards,
> >
> > > Gary
> >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> > >For additional commands, e-mail: torque-dev-help@db.apache.org
> >
> > --
> > Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> > hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
> >
> > Java, perl, Solaris, Linux, xSP Consulting, Web Services
> > freelance consultant -- Jakarta Turbine Development -- hero for hire
> >
> > "Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
> > -- AOL CD when played backwards (User Friendly - 200-10-15)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-dev-help@db.apache.org
> >
> >
> >
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
Java, perl, Solaris, Linux, xSP Consulting, Web Services
freelance consultant -- Jakarta Turbine Development -- hero for hire
"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
-- AOL CD when played backwards (User Friendly - 200-10-15)
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: DatabaseMap empty except for ID_TABLE?
Posted by Gary Shea <sh...@gtsdesign.com>.
Hi Henning --
Thanks for the pointer. I was stuck on something much simpler than
the relatively sophisticated problem you described.
I read your post about the collection of changes you posted a week or
two ago. I was wondering... I've been looking for a way to build
bits of a database schema (in hsql, with memory model) on the fly for unit
testing. I have not found a good tool for doing it. Torque knows
how, but is oriented towards a batch mode where it builds the entire db
schema at once. I haven't tried modifying it yet, but wondered if your
changes make that code more modular.
Gary
[2003-10-30 15:23 -0000] Henning P. Schmiedehausen (hps@intermeta.de) wrote:
> Gary Shea <sh...@gtsdesign.com> writes:
>
> >I'm trying to track down a problem. I've been using Torque naively but
> >successfully for the last couple of months, but my first attempt to get
> >a little fancy has not been successful.
>
> As the table peers are static, you must access the peers first, before
> they get added to the dbMap.
>
> Try
>
> String dummy = RC4Peer.TABLE_NAME + SummaryPeer.TABLE_NAME;
>
> and then do it again. Better yet, lobby for my proposal. ;-)
>
> Regards
> Henning
>
>
> >I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
> >and running into a NPE at the line:
> > ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
>
> >The application is using two databases ("rc4" and "summary"); at the
> >point of the NPE I have already successfully SELECTed from both and INSERTed
> >into "summary". I tried the following test code (basically the
> >beginning of doUpdate()):
>
> > DB db = Torque.getDB(poolName);
> > DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
> > _logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
>
> > String dbMapName = dbMap.getName();
> > _logger.debug("dbMapName: " + dbMapName);
>
> > TableMap[] tableMaps = dbMap.getTables();
> > for (int i = 0; i < tableMaps.length; ++i) {
> > _logger.debug(i + ": " + tableMaps[i].getName());
> > }
> > TableMap tableMap = dbMap.getTable(poolTable);
> > _logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
>
> >For poolName set to either "rc4" or "summary", the only tableMap found
> >is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
> >returns null, hence the NPE in the Torque code.
>
> >Any hints?
>
> >Regards,
>
> > Gary
>
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> >For additional commands, e-mail: torque-dev-help@db.apache.org
>
> --
> Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
>
> Java, perl, Solaris, Linux, xSP Consulting, Web Services
> freelance consultant -- Jakarta Turbine Development -- hero for hire
>
> "Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
> -- AOL CD when played backwards (User Friendly - 200-10-15)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: DatabaseMap empty except for ID_TABLE?
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
Gary Shea <sh...@gtsdesign.com> writes:
>I'm trying to track down a problem. I've been using Torque naively but
>successfully for the last couple of months, but my first attempt to get
>a little fancy has not been successful.
As the table peers are static, you must access the peers first, before
they get added to the dbMap.
Try
String dummy = RC4Peer.TABLE_NAME + SummaryPeer.TABLE_NAME;
and then do it again. Better yet, lobby for my proposal. ;-)
Regards
Henning
>I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
>and running into a NPE at the line:
> ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
>The application is using two databases ("rc4" and "summary"); at the
>point of the NPE I have already successfully SELECTed from both and INSERTed
>into "summary". I tried the following test code (basically the
>beginning of doUpdate()):
> DB db = Torque.getDB(poolName);
> DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
> _logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
> String dbMapName = dbMap.getName();
> _logger.debug("dbMapName: " + dbMapName);
> TableMap[] tableMaps = dbMap.getTables();
> for (int i = 0; i < tableMaps.length; ++i) {
> _logger.debug(i + ": " + tableMaps[i].getName());
> }
> TableMap tableMap = dbMap.getTable(poolTable);
> _logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
>For poolName set to either "rc4" or "summary", the only tableMap found
>is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
>returns null, hence the NPE in the Torque code.
>Any hints?
>Regards,
> Gary
>---------------------------------------------------------------------
>To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
>For additional commands, e-mail: torque-dev-help@db.apache.org
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
Java, perl, Solaris, Linux, xSP Consulting, Web Services
freelance consultant -- Jakarta Turbine Development -- hero for hire
"Dominate!! Dominate!! Eat your young and aggregate! I have grotty silicon!"
-- AOL CD when played backwards (User Friendly - 200-10-15)
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
Re: DatabaseMap empty except for ID_TABLE?
Posted by Gary Shea <sh...@gtsdesign.com>.
I finally tracked down that my Torque classes all have "default"
hard-coded into them, as in
dbMap = Torque.getDatabaseMap("default");
so that the only database map that is properly initialized is "default",
which has picked up the database map entries for both my databases. I'm
guessing this is a configuration error on my part. Now I just have to
figure out how to configure it properly...
Gary
[2003-10-29 20:26 -0700] Gary Shea (shea@gtsdesign.com) wrote:
> I'm trying to track down a problem. I've been using Torque naively but
> successfully for the last couple of months, but my first attempt to get
> a little fancy has not been successful.
>
> I'm trying to do an update using doUpdate(Criteria,Criteria,Connection)
> and running into a NPE at the line:
> ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();
>
> The application is using two databases ("rc4" and "summary"); at the
> point of the NPE I have already successfully SELECTed from both and INSERTed
> into "summary". I tried the following test code (basically the
> beginning of doUpdate()):
>
> DB db = Torque.getDB(poolName);
> DatabaseMap dbMap = Torque.getDatabaseMap(selectCriteria.getDbName());
> _logger.debug("DB: " + db + " DatabaseMap: " + dbMap);
>
> String dbMapName = dbMap.getName();
> _logger.debug("dbMapName: " + dbMapName);
>
> TableMap[] tableMaps = dbMap.getTables();
> for (int i = 0; i < tableMaps.length; ++i) {
> _logger.debug(i + ": " + tableMaps[i].getName());
> }
> TableMap tableMap = dbMap.getTable(poolTable);
> _logger.debug("table name: " + poolTable + " tableMap: " + tableMap);
>
> For poolName set to either "rc4" or "summary", the only tableMap found
> is for ID_TABLE. Likewise, in both cases dbMap.getTable(poolTable)
> returns null, hence the NPE in the Torque code.
>
> Any hints?
>
> Regards,
>
> Gary
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org