You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Simon Roberts <si...@fifthweb.net> on 2002/12/03 21:50:22 UTC

Torque and multiple databases with the same schema

Giddy,

I've got a little problem that I'm hoping some of you can offer insight
into.  If it's a bug, or desired feature, I'm more than willing to
add/contribute it, but I want to make sure I'm not barking up the wrong tree
first.

I have an appserver-type thing that we've just started to port to Torque,
but are running up against a problem: the program needs to talk to N
different databases, configured at runtime (all with the same schema).

Is there *any* support for this kind of thing?    I can see that the Ant
tasks support explicit configuration, so it should be possible to drive it
from ant.

Also, if I configure a schema with <database name="node1"> and then call
someRecord.save("node2") why is it that node1's databasemap is updated, not
node2?

Cheers, Simon





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque and multiple databases with the same schema

Posted by Simon Roberts <si...@fifthweb.net>.
"John McNally" <jm...@collab.net> wrote in message
news:1038956690.668.31.camel@localhost.localdomain...
> You should not use the name attribute on <database> if the torque
> objects are going to work with multiple databases.

In which case, it just doesn't work at all:

<database defaultIdMethod="native">
    <table name="publisher" idMethod="native">
        <column name="publisher_id" required="true" primaryKey="true"
type="INTEGER"/>
        <column name="name" required="true" type="VARCHAR" size="128" />
    </table>
</database>

Attempting to do:

        Author author = new Author();
        author.setFirstName("Jack");
        author.setFirstName("Daniels");
        author.save("node2");

Dies with the following message and error:

16:16:59 [WARN ] main IDBroker.<init>: IDBroker is being used with db
'default', which does not support transactions. IDBroker attempts to use
transactions to limit the possibility of duplicate key generation.  Without
transactions, duplicate key generation is possible if multiple JVMs are used
or other means are used to write to the database.
E
Time: 1.732
There was 1 error:
1)
testAddAuthor(fifthweb.jag.server.store.torque.test.TestBookstore)org.apache
.torque.TorqueException: IdGenerator for table 'author' is null
 at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:690)
 at
fifthweb.jag.server.store.torque.BaseAuthorPeer.doInsert(BaseAuthorPeer.java
:216)
 at
fifthweb.jag.server.store.torque.BaseAuthorPeer.doInsert(BaseAuthorPeer.java
:565)
 at fifthweb.jag.server.store.torque.BaseAuthor.save(BaseAuthor.java:508)
 at fifthweb.jag.server.store.torque.BaseAuthor.save(BaseAuthor.java:470)
 at
fifthweb.jag.server.store.torque.test.TestBookstore.testAddAuthor(TestBookst
ore.java:74)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


I'm not using any DB called "default".  I have no torque.database.default
property defined.  I don't want any IDBroker.

This relates to a bug/situation I reported elsewhere (where it is using
DB_NAME (default) instead of "node2" when creating the Criteria for
inserting. Even if I create a Criteria manually, it does with the same
message.  The DataBase map is empty.

Big Question : how is the DatabaseMap supposed to get initialized?

Cheers, Simon






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque and multiple databases with the same schema

Posted by John McNally <jm...@collab.net>.
not sure what you mean by databasemap below save("foo") is just going to
insert or update a row, it will not affect DatabaseMap.
You should not use the name attribute on <database> if the torque
objects are going to work with multiple databases.

john mcnally

On Tue, 2002-12-03 at 12:50, Simon Roberts wrote:
> Giddy,
> 
> I've got a little problem that I'm hoping some of you can offer insight
> into.  If it's a bug, or desired feature, I'm more than willing to
> add/contribute it, but I want to make sure I'm not barking up the wrong tree
> first.
> 
> I have an appserver-type thing that we've just started to port to Torque,
> but are running up against a problem: the program needs to talk to N
> different databases, configured at runtime (all with the same schema).
> 
> Is there *any* support for this kind of thing?    I can see that the Ant
> tasks support explicit configuration, so it should be possible to drive it
> from ant.
> 
> Also, if I configure a schema with <database name="node1"> and then call
> someRecord.save("node2") why is it that node1's databasemap is updated, not
> node2?
> 
> Cheers, Simon
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>