// Set the correct dbName if it has not been overridden
// criteria.getDbName will return the same object if not set
to
// another value so == check is okay and faster
if ( criteria.getDbName() == Torque.getDefaultDB() )
{
criteria.setDbName(DATABASE_NAME);
}
[EMAIL PROTECTED] wrote:
...
>
> When Turbine initializes, it comes up with one database connection pool
> named 'default'. My database is named 'ANALYSEN', though, in the
> analysen-schema.xml file. Hence, I could never get the OM complex to work
> at all. I run Torque/OM separated from Turbine.
Torque creates a pool and assigns it to whatever name you use, it will
only create a pool named 'default' if you use that handle in specifying
the connection pool properties.
>
> Then i started getting DBConnections separately and then it worked until I
> tried to get an instance of a related table, then I got exceptions (no
> [database] connection) again.
>
> Now, the code generated by Torque assumes that there should be a connection
> pool named after the database and there isn't in my case. Turbine
> initializes with a connection pool named 'default' which the OM classes
> will never use!
>
> After initialising Turbine I now create a new database connection pool
> named 'ANALYSEN' and now I can get instances of related objects from the
> OM.
I assume you deleted the connection pool named 'default' as you have no
need for it. I do not understand why you say Turbine did this when it
is only creating connection pools you have specified in your properties
file.
>
> But I could not set the 'ORDER BY' clause, which I have to since I get rows
> returned in reverse order from how they are stored in the database and
> they're not even in the correct order in the database.
>
> During the criteria.addAscendingOrderBy(), the database map is bult using
> the database name of 'ANALYSEN' since that is how I named it. The criteria
> instance, however, refers to the name 'default'.
>
> When the query-string is put together, though, the name in the criteria
> sent as an argument is used, and that is 'default'!
>
> The exception occurs in class BasePeer extended by the <table-name>Peer
> class in method createQueryString() at line 1039 where the call to
> ColumnMap column = dbMap.getTable(table).getColumn( columnName ) causes a
> null pointer exception.
Methods in the generated BaseXXXPeer classes have the following code:
// BasePeer returns a Vector of Value (Village) arrays. The
array
// order follows the order columns were placed in the Select
clause.
if ( dbCon == null)
{
// Set the correct dbName if it has not been overridden
// criteria.getDbName will return the same object if not set
to
// another value so == check is okay and faster
if ( criteria.getDbName() == Torque.getDefaultDB() )
{
criteria.setDbName(DATABASE_NAME);
}
return BasePeer.doSelect(criteria);
}
else
{
return BasePeer.doSelect(criteria, dbCon);
}
where DATABASE_NAME in your case is going to be ANALYSEN. It seems this
code should be moved outside the null check. Are you passing in a
connection to FooPeer.doSelect? Otherwise setting the correct dbName
should be handled by the code given above.
john mcnally
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>