You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Scott Eade <se...@backstagetech.com.au> on 2003/02/05 06:35:10 UTC

Attn: PostgreSQL users

I am toying with the idea of switching from MySQL to PostgreSQL and so I am
looking through all of the problems people seem to be having.  I have
summarised my findings so far on the wiki:

http://nagoya.apache.org/wiki/apachewiki.cgi?TorqueProjectPages/PostgreSQLFA
Q

If the existing PostgreSQL users can add to this page it would he helpful
not only to me, but also to everyone else that is either currently using or
considering using PostgreSQL.

I will commit the four noted issues, as long as I can get confirmation that
they are necessary (and after I am able to access the new db-torque cvs
module).

If we can flesh the other points out we should be able to integrate the
result back into the postgresql-howto.

Note that as things currently stand I don't think I am going to have the
time necessary to actually switch to PostgreSQL, but most of the highlighted
issues seem fairly close to resolution so we may as well attack them.

Cheers,

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com


Re: Attn: PostgreSQL users

Posted by CP Lim <cp...@redsheriff.com>.
Hi Scott,

The DATABASE_NAME is initialised to "default" for all Base*Peer classes. 
  Is this correct?  (I hope so)

Had a look at my generated Base*Peer class code, and in particular 
looked at the generated 'public static ObjectKey doInsert(Criteria, 
Connection)' method, and the first thing it does is checks the following:

------------------------------------------
if (criteria.getDbName() == Torque.getDefaultDB())
{
     criteria.setDbName(DATABASE_NAME);
}
------------------------------------------

I'm going to change the configuration (Torque.properties) a few times 
and see if it affects the processing of the (subsequent call to ) 
BasePeer.doInsert() method.  However, I'm not terribly familiar with the 
structure and purpose of the Torque code, so am not sure if I'm looking 
in the correct places to try and analyse the crux of the problem.

Anyway, thanks for the input so far.  Will post back to list when I get 
something more concrete.

cheers,
CP


Scott Eade wrote:
> I am wondering if it is a generation time vs. a runtime thing.  What is
> DATABASE_NAME initialised to in the generated Base*Peer classes?
> 
> The runtime Torque.properties can be configured to handle multiple
> databases.  You configure a dsfactory for each database and map a physical
> database to the logical database name that is used internally by torque.
> The torque.database.default property is used to configure which dsfactory
> should be used when one is not provided to a query (although I suspect
> torque is really using the DATABASE_NAME property generated into the
> Base*Peer class).
> 
> HTH,
> 
> Scott


-- 
R E D S H E R I F F
C.P. Lim - Software Engineer
Level 1, 10 Queens Road    +61 3 9864 0733 tel
Melbourne VIC              +61 3 9864 0778 fax
Australia                  +61 413 781 846 mob

This message and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you are not the intended recipient, you are hereby 
notified that any use or dissemination of this communication is strictly 
prohibited. If you have received this message in error please notify us 
immediately by return email or telephone +61 (3) 9659 0432, then delete 
this message. Any views expressed in this message are those of the 
individual sender and many not necessarily reflect the views of Red 
Sheriff.


Re: Attn: PostgreSQL users

Posted by Scott Eade <se...@backstagetech.com.au>.
I am wondering if it is a generation time vs. a runtime thing.  What is
DATABASE_NAME initialised to in the generated Base*Peer classes?

The runtime Torque.properties can be configured to handle multiple
databases.  You configure a dsfactory for each database and map a physical
database to the logical database name that is used internally by torque.
The torque.database.default property is used to configure which dsfactory
should be used when one is not provided to a query (although I suspect
torque is really using the DATABASE_NAME property generated into the
Base*Peer class).

HTH,

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com



On 7/02/2003 9:30 AM, "CP Lim" <cp...@redsheriff.com> wrote:

> Hi Scott,
> 
> Been using postgreSQL and Torque (v3.0) for a while now and was reading
> through your FAQ and looking at the section on using "native"
> (sequences) jogged my memory on my Torque.properties file.
> 
> My Torque settings are is as follows:
> 
> -------------------------------------
> torque.database.default=drop4
> torque.database.default.adapter=postgresql #its using 'default' as name
> -------------------------------------
> 
> which has a different _property name_ from the default setting supplied
> by the newapp application:
> 
> -------------------------------------
> torque.database.default=newapp
> torque.database.newapp.adapter=postgresql # using 'newapp' as name
> -------------------------------------
> 
> If I changed my settings to mirror that of newapp's, ie.
> 
> -------------------------------------
> torque.database.default=drop4
> torque.database.drop4.adapter=postgresql
> -------------------------------------
> 
> I can no longer insert into the table and the following exception is thrown
> -------------------------------------
> Caused by: org.apache.torque.TorqueException: IdGenerator for table
> 'rs_user' is null
> at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:690)
> at 
> com.redsheriff.core.torque.BaseRsUserPeer.doInsert(BaseRsUserPeer.java:267)
> at 
> com.redsheriff.core.torque.BaseRsUserPeer.doInsert(BaseRsUserPeer.java:652)
> at com.redsheriff.core.torque.BaseRsUser.save(BaseRsUser.java:1039)
> at com.redsheriff.admeasure.core.AMUserMgr.save(AMUserMgr.java:371)
> -------------------------------------
> 
> I've debugged through the Torque v3.0 source and it looks like in the
> BasePeer.doInsert(Criteria, Connection) method,  the IdGenerator object
> returned (line 674) is null.  Examining this further it turns out that
> the DatabaseMap object does in fact contain a reference to the native
> IdGenerator, but is mapped to the name 'drop4'.  So when its configured
> as above (I think) its using 'default' as the key so null (IdGenerator)
> is returned.
> 
> My question is: Is this a bug or have I misunderstood the
> Torque.properties configuration file?
> 
> (Sorry about the long winded email, but had to illustrate what I was
> experiencing).
> 
> cheers,
> CP
> 
> 
> Scott Eade wrote:
>> I am toying with the idea of switching from MySQL to PostgreSQL and so I am
>> looking through all of the problems people seem to be having.  I have
>> summarised my findings so far on the wiki:
>> 
>> http://nagoya.apache.org/wiki/apachewiki.cgi?TorqueProjectPages/PostgreSQLFA
>> Q
>> 
>> If the existing PostgreSQL users can add to this page it would he helpful
>> not only to me, but also to everyone else that is either currently using or
>> considering using PostgreSQL.
>> 
>> I will commit the four noted issues, as long as I can get confirmation that
>> they are necessary (and after I am able to access the new db-torque cvs
>> module).
>> 
>> If we can flesh the other points out we should be able to integrate the
>> result back into the postgresql-howto.
>> 
>> Note that as things currently stand I don't think I am going to have the
>> time necessary to actually switch to PostgreSQL, but most of the highlighted
>> issues seem fairly close to resolution so we may as well attack them.
>> 
>> Cheers,
>> 
>> Scott
> 


Re: Attn: PostgreSQL users

Posted by CP Lim <cp...@redsheriff.com>.
Hi Scott,

Been using postgreSQL and Torque (v3.0) for a while now and was reading 
through your FAQ and looking at the section on using "native" 
(sequences) jogged my memory on my Torque.properties file.

My Torque settings are is as follows:

-------------------------------------
torque.database.default=drop4
torque.database.default.adapter=postgresql #its using 'default' as name
-------------------------------------

which has a different _property name_ from the default setting supplied 
by the newapp application:

-------------------------------------
torque.database.default=newapp
torque.database.newapp.adapter=postgresql # using 'newapp' as name
-------------------------------------

If I changed my settings to mirror that of newapp's, ie.

-------------------------------------
torque.database.default=drop4
torque.database.drop4.adapter=postgresql
-------------------------------------

I can no longer insert into the table and the following exception is thrown
-------------------------------------
Caused by: org.apache.torque.TorqueException: IdGenerator for table 
'rs_user' is null
	at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:690)
	at 
com.redsheriff.core.torque.BaseRsUserPeer.doInsert(BaseRsUserPeer.java:267)
	at 
com.redsheriff.core.torque.BaseRsUserPeer.doInsert(BaseRsUserPeer.java:652)
	at com.redsheriff.core.torque.BaseRsUser.save(BaseRsUser.java:1039)
	at com.redsheriff.admeasure.core.AMUserMgr.save(AMUserMgr.java:371)
-------------------------------------

I've debugged through the Torque v3.0 source and it looks like in the 
BasePeer.doInsert(Criteria, Connection) method,  the IdGenerator object 
returned (line 674) is null.  Examining this further it turns out that 
the DatabaseMap object does in fact contain a reference to the native 
IdGenerator, but is mapped to the name 'drop4'.  So when its configured 
as above (I think) its using 'default' as the key so null (IdGenerator) 
is returned.

My question is: Is this a bug or have I misunderstood the 
Torque.properties configuration file?

(Sorry about the long winded email, but had to illustrate what I was 
experiencing).

cheers,
CP


Scott Eade wrote:
> I am toying with the idea of switching from MySQL to PostgreSQL and so I am
> looking through all of the problems people seem to be having.  I have
> summarised my findings so far on the wiki:
> 
> http://nagoya.apache.org/wiki/apachewiki.cgi?TorqueProjectPages/PostgreSQLFA
> Q
> 
> If the existing PostgreSQL users can add to this page it would he helpful
> not only to me, but also to everyone else that is either currently using or
> considering using PostgreSQL.
> 
> I will commit the four noted issues, as long as I can get confirmation that
> they are necessary (and after I am able to access the new db-torque cvs
> module).
> 
> If we can flesh the other points out we should be able to integrate the
> result back into the postgresql-howto.
> 
> Note that as things currently stand I don't think I am going to have the
> time necessary to actually switch to PostgreSQL, but most of the highlighted
> issues seem fairly close to resolution so we may as well attack them.
> 
> Cheers,
> 
> Scott


-- 
R E D S H E R I F F
C.P. Lim - Software Engineer
Level 1, 10 Queens Road    +61 3 9864 0733 tel
Melbourne VIC              +61 3 9864 0778 fax
Australia                  +61 413 781 846 mob

This message and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you are not the intended recipient, you are hereby 
notified that any use or dissemination of this communication is strictly 
prohibited. If you have received this message in error please notify us 
immediately by return email or telephone +61 (3) 9659 0432, then delete 
this message. Any views expressed in this message are those of the 
individual sender and many not necessarily reflect the views of Red 
Sheriff.