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 Marc Lustig <ma...@marclustig.com> on 2003/01/12 23:47:46 UTC
IDBroker /ID_TABLE problem
Hi,
I have just set the fields of my BO and tried to save() to create a new row.
Torque complains:
java.lang.reflect.InvocationTargetException:
org.apache.torque.TorqueException: The table MY_TABLE does not have a proper
entry in the ID_TABLE at
org.apache.torque.oid.IDBroker.selectRow(IDBroker.java:803) at
org.apache.torque.oid.IDBroker.storeIDs(IDBroker.java:665) at
org.apache.torque.oid.IDBroker.getNextIds(IDBroker.java:441) at
org.apache.torque.oid.IDBroker.getIdAsBigDecimal(IDBroker.java:329) at
org.apache.torque.util.BasePeer.doInsert(BasePeer.java:702) at
My schema is set to defaultIdMethod="idbroker".
My id_table is completely empty.
What's the problem here?
Can anybody give me a hint?
Marc
AW: IDBroker /ID_TABLE problem
Posted by Marc Lustig <ma...@marclustig.com>.
There is a maven-target torque:insert-sql
But I'm not quite sure whether this processes the inserts for id_table as
well.
Also, I wonder what happens if I recreate the sql with new tables.
Can I just insert all the id_table entries once again and overwrite the old
rows?
Or does this cause trouble for the IDBroker?
When I create a new table what I did was only inserting the inserts for the
new table.
It is necessary then to replace the primary key with the next one available
in my existing id_table. That I find a bit annoying.
Marc
> -----Ursprüngliche Nachricht-----
> Von: Dan Tran [mailto:danttran@hotmail.com]
> Gesendet: Dienstag, 14. Januar 2003 00:33
> An: Turbine Torque Users List
> Betreff: Re: IDBroker /ID_TABLE problem
>
>
> I have complained about this before, but the answer is your have to write
> your own script to prepopulate id_table. I find it very annoying
>
> Is this a bug?
>
> -D
> ----- Original Message -----
> From: "Marc Lustig" <ma...@marclustig.com>
> To: "Turbine Torque Users List" <tu...@jakarta.apache.org>
> Sent: Monday, January 13, 2003 1:06 AM
> Subject: AW: IDBroker /ID_TABLE problem
>
>
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Peter Courcoux [mailto:peter@courcoux.biz]
> > > Gesendet: Montag, 13. Januar 2003 01:57
> > > An: Turbine Torque Users List
> > > Betreff: Re: IDBroker /ID_TABLE problem
> > >
> > >
> > > Marc,
> > >
> > > When you run ant init it should create the id_table which I suspect it
> > > does. It should also then run an ant target to insert into
> the id_table
> > > a line for each of the tables in your schema.
> >
> > I'm using Maven for building (which should be no difference to
> using ant,
> > since the torque-plugin-goals is just wrapped around the ant targets)
> > Then I trigger torque:id-table-init-sql maven reports BUILD SUCCESSFUL,
> but
> > still no data is put into my id_table?
> >
> > Any further suggesstion ?
> >
> > Thanks!
> > Marc
> >
> >
> > --
> > 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>
Re: IDBroker /ID_TABLE problem
Posted by Dan Tran <da...@hotmail.com>.
I have complained about this before, but the answer is your have to write
your own script to prepopulate id_table. I find it very annoying
Is this a bug?
-D
----- Original Message -----
From: "Marc Lustig" <ma...@marclustig.com>
To: "Turbine Torque Users List" <tu...@jakarta.apache.org>
Sent: Monday, January 13, 2003 1:06 AM
Subject: AW: IDBroker /ID_TABLE problem
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Peter Courcoux [mailto:peter@courcoux.biz]
> > Gesendet: Montag, 13. Januar 2003 01:57
> > An: Turbine Torque Users List
> > Betreff: Re: IDBroker /ID_TABLE problem
> >
> >
> > Marc,
> >
> > When you run ant init it should create the id_table which I suspect it
> > does. It should also then run an ant target to insert into the id_table
> > a line for each of the tables in your schema.
>
> I'm using Maven for building (which should be no difference to using ant,
> since the torque-plugin-goals is just wrapped around the ant targets)
> Then I trigger torque:id-table-init-sql maven reports BUILD SUCCESSFUL,
but
> still no data is put into my id_table?
>
> Any further suggesstion ?
>
> Thanks!
> Marc
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
AW: IDBroker /ID_TABLE problem [fixed]
Posted by Marc Lustig <ma...@marclustig.com>.
Thanks, I just stumbled over a sql-file that was produced by torque
containing the inserts for id_table.
I can just pick this up and insert it into my db.
Thanks, Peter and Scott.
Marc
> -----Ursprüngliche Nachricht-----
> Von: Marc Lustig [mailto:mail@marclustig.com]
> Gesendet: Montag, 13. Januar 2003 10:07
> An: Turbine Torque Users List
> Betreff: AW: IDBroker /ID_TABLE problem
>
>
>
>
> > -----Ursprüngliche Nachricht-----
> > Von: Peter Courcoux [mailto:peter@courcoux.biz]
> > Gesendet: Montag, 13. Januar 2003 01:57
> > An: Turbine Torque Users List
> > Betreff: Re: IDBroker /ID_TABLE problem
> >
> >
> > Marc,
> >
> > When you run ant init it should create the id_table which I suspect it
> > does. It should also then run an ant target to insert into the id_table
> > a line for each of the tables in your schema.
>
> I'm using Maven for building (which should be no difference to using ant,
> since the torque-plugin-goals is just wrapped around the ant targets)
> Then I trigger torque:id-table-init-sql maven reports BUILD
> SUCCESSFUL, but
> still no data is put into my id_table?
>
> Any further suggesstion ?
>
> Thanks!
> Marc
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
AW: IDBroker /ID_TABLE problem
Posted by Marc Lustig <ma...@marclustig.com>.
> -----Ursprüngliche Nachricht-----
> Von: Peter Courcoux [mailto:peter@courcoux.biz]
> Gesendet: Montag, 13. Januar 2003 01:57
> An: Turbine Torque Users List
> Betreff: Re: IDBroker /ID_TABLE problem
>
>
> Marc,
>
> When you run ant init it should create the id_table which I suspect it
> does. It should also then run an ant target to insert into the id_table
> a line for each of the tables in your schema.
I'm using Maven for building (which should be no difference to using ant,
since the torque-plugin-goals is just wrapped around the ant targets)
Then I trigger torque:id-table-init-sql maven reports BUILD SUCCESSFUL, but
still no data is put into my id_table?
Any further suggesstion ?
Thanks!
Marc
Re: IDBroker /ID_TABLE problem
Posted by Peter Courcoux <pe...@courcoux.biz>.
Marc,
When you run ant init it should create the id_table which I suspect it
does. It should also then run an ant target to insert into the id_table
a line for each of the tables in your schema.
I have one project where it does this ok and one where the ant target is
called out of sequence and fails to insert the lines. When it fails the
messages output by 'ant init' show the insert into id_table entries
failing. I have not spent the time to fix this properly but as a
workaround, afer running ant init, run the yourschema-idtable-init.sql
and turbine-schema-idtable-init.sql files containing the id table insert
sql statments which are generated by ant against the database. The init
sql files are in WEB-INF/src/sql directory.
If you find that this is the answer, I think there was a thread some
months ago about ant targets being run out of sequence. You may find a
proper fix there.
I hope that this helps.
Peter
On Sun, 2003-01-12 at 22:47, Marc Lustig wrote:
> Hi,
> I have just set the fields of my BO and tried to save() to create a new row.
> Torque complains:
>
> java.lang.reflect.InvocationTargetException:
> org.apache.torque.TorqueException: The table MY_TABLE does not have a proper
> entry in the ID_TABLE at
> org.apache.torque.oid.IDBroker.selectRow(IDBroker.java:803) at
> org.apache.torque.oid.IDBroker.storeIDs(IDBroker.java:665) at
> org.apache.torque.oid.IDBroker.getNextIds(IDBroker.java:441) at
> org.apache.torque.oid.IDBroker.getIdAsBigDecimal(IDBroker.java:329) at
> org.apache.torque.util.BasePeer.doInsert(BasePeer.java:702) at
>
> My schema is set to defaultIdMethod="idbroker".
> My id_table is completely empty.
> What's the problem here?
> Can anybody give me a hint?
>
> Marc
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Peter Courcoux <pe...@courcoux.biz>
Solved: was: Transaction Error: Postgresql <=> Torque
Posted by goffredo <go...@twibble.org>.
Hi Steve,
Thanks for your clarification,
[...]
> It is not saying the RDBMS does not support transactions, its telling
> us, for some reason IDBroker can not use transactions with the
> db 'bookstore' it found defined in our configuration, there are
> probably many possible reasons for this but I've run into
> 1) bad configuation of the database, and 2) incorrect login
> information as the most common problems.
After checking with pg_shadow and other things, I finally found the
offending line:
torque.dsfactory.bookstore.connection.user = "goffredo"
Of course it's obvious - there should be no java-style double quotes
around the user name!! The Postgresql user is goffredo, not "goffredo"
- ah the joys of programming. ;)
Thanks
Goffredo
Re: Transaction Error: Postgresql <=> Torque
Posted by Steve Hansen <st...@sinex.com>.
Hello,
When I've seen errors like this it usually means I've miss configured
the runtime configuration file. When torque is complaining a database is
not using transactions ..
WARN - IDBroker is being used with db 'bookstore',
> which does not support transactions. <--- for Postgresql ?????It is not saying the RDBMS does not support transactions, its telling us, for some
reason IDBroker can not use transactions with the db 'bookstore' it
found defined in our configuration, there are probably many possible
reasons for this but I've run into 1) bad configuation of the database,
and 2) incorrect login information as the most common problems.
Steve
On Sun, 2003-01-12 at 20:44, goffredo wrote:
> Hi,
>
But when I tried to run it I got a mysterious error, a warning
> in the torque.log stating that the Postgresql 'bookstore' database
> does not support transactions (???) Of course Postgresql supports
> transactions ... I am not sure at all where the problem lies - my
> configuration, my startup of Postgresql - or what - I enclose the
> relevant notes, perhaps someone can spot the fault right away ... and
> let me know
>
> Regards
> goffredo
>
> Error Message :
> ---------------
>
> java.lang.NullPointerException: Connection object was null.
> This could be due to a misconfiguration of the DataSourceFactory.
> Check the logs and Torque.properties to better determine the cause.
> at org.apache.torque.util.Transaction.rollback(Transaction.java:179)
> at org.apache.torque.util.Transaction.safeRollback(Transaction.java:221)
> at org.armida.mbrowser.torque.om.BasePublisher.save(BasePublisher.java:426)
> at org.armida.mbrowser.torque.om.BasePublisher.save(BasePublisher.java:401)
> at Bookstore.main(Bookstore.java:26)
>
>
> Offending Class :
> -----------------
> public void save(String dbName) throws TorqueException
> {
> Connection con = null;
> try
> {
> con = Transaction.begin(dbName);
> save(con);
> Transaction.commit(con);
> }
> catch(TorqueException e)
> {
> Transaction.safeRollback(con); [ <--- line 179 ]
> throw e;
> }
>
> }
>
> Last Few Lines of torque.log :
> ------------------------------
>
> [...]
> DEBUG - Using converter
> org.apache.commons.beanutils.converters.StringConverter@3901c6
> DEBUG - Adding a dummy entry for default, mapped onto bookstore
> DEBUG - IDBroker thread was started.
> WARN - IDBroker is being used with db 'bookstore',
> which does not support transactions. <--- for Postgresql ??????
> 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.
>
>
> torque.properties :
> -------------------
>
> torque.applicationRoot = .
>
> log4j.category.org.apache.torque = ALL, org.apache.torque
> log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
> log4j.appender.org.apache.torque.file =
> ${torque.applicationRoot}/logs/torque.log
> log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
> log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t] %-5p %c - %
> m%n
> log4j.appender.org.apache.torque.append = false
>
> torque.database.default=bookstore
> torque.database.bookstore.adapter=postgresql
>
> log4j.rootCategory = DEBUG, default
> log4j.appender.default = org.apache.log4j.FileAppender
> log4j.appender.default.file = ./torque.log
> log4j.appender.default.layout = org.apache.log4j.SimpleLayout
>
>
> ## Using Jdbc2Pool
> torque.dsfactory.bookstore.factory=\
> org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
> torque.dsfactory.bookstore.pool.defaultMaxActive=10
> torque.dsfactory.bookstore.pool.testOnBorrow=true
> torque.dsfactory.bookstore.pool.validationQuery=SELECT 1
> torque.database.bookstore.driver = org.postgresql.Driver
> torque.database.bookstore.url = jdbc:postgresql://192.168.1.1:5432/bookstore
> torque.dsfactory.bookstore.connection.user = <user>
> torque.dsfactory.bookstore.connection.password = <password>
>
> torque.idbroker.cleverquantity=true
> torque.manager.useCache = true
>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
Transaction Error: Postgresql <=> Torque
Posted by goffredo <go...@twibble.org>.
Hi,
I am working through the bookstore tutorial, and am making some
progress. If people think it's ok, I could make my notes available
for inclusion in the tutorial - there are database specific things
that are important, that are not mentioned. For example, I still
haven't been able to get torque to create-db the 'bookstore' database
for me, so I did it by hand, then the loading of the db seemed
to go ok. Next I embedded the torque source tree into CodeGuide (an IDE)
as a new project and created the tutorial application. It compiled
fine. But when I tried to run it I got a mysterious error, a warning
in the torque.log stating that the Postgresql 'bookstore' database
does not support transactions (???) Of course Postgresql supports
transactions ... I am not sure at all where the problem lies - my
configuration, my startup of Postgresql - or what - I enclose the
relevant notes, perhaps someone can spot the fault right away ... and
let me know
Regards
goffredo
Error Message :
---------------
java.lang.NullPointerException: Connection object was null.
This could be due to a misconfiguration of the DataSourceFactory.
Check the logs and Torque.properties to better determine the cause.
at org.apache.torque.util.Transaction.rollback(Transaction.java:179)
at org.apache.torque.util.Transaction.safeRollback(Transaction.java:221)
at org.armida.mbrowser.torque.om.BasePublisher.save(BasePublisher.java:426)
at org.armida.mbrowser.torque.om.BasePublisher.save(BasePublisher.java:401)
at Bookstore.main(Bookstore.java:26)
Offending Class :
-----------------
public void save(String dbName) throws TorqueException
{
Connection con = null;
try
{
con = Transaction.begin(dbName);
save(con);
Transaction.commit(con);
}
catch(TorqueException e)
{
Transaction.safeRollback(con); [ <--- line 179 ]
throw e;
}
}
Last Few Lines of torque.log :
------------------------------
[...]
DEBUG - Using converter
org.apache.commons.beanutils.converters.StringConverter@3901c6
DEBUG - Adding a dummy entry for default, mapped onto bookstore
DEBUG - IDBroker thread was started.
WARN - IDBroker is being used with db 'bookstore',
which does not support transactions. <--- for Postgresql ??????
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.
torque.properties :
-------------------
torque.applicationRoot = .
log4j.category.org.apache.torque = ALL, org.apache.torque
log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
log4j.appender.org.apache.torque.file =
${torque.applicationRoot}/logs/torque.log
log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t] %-5p %c - %
m%n
log4j.appender.org.apache.torque.append = false
torque.database.default=bookstore
torque.database.bookstore.adapter=postgresql
log4j.rootCategory = DEBUG, default
log4j.appender.default = org.apache.log4j.FileAppender
log4j.appender.default.file = ./torque.log
log4j.appender.default.layout = org.apache.log4j.SimpleLayout
## Using Jdbc2Pool
torque.dsfactory.bookstore.factory=\
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
torque.dsfactory.bookstore.pool.defaultMaxActive=10
torque.dsfactory.bookstore.pool.testOnBorrow=true
torque.dsfactory.bookstore.pool.validationQuery=SELECT 1
torque.database.bookstore.driver = org.postgresql.Driver
torque.database.bookstore.url = jdbc:postgresql://192.168.1.1:5432/bookstore
torque.dsfactory.bookstore.connection.user = <user>
torque.dsfactory.bookstore.connection.password = <password>
torque.idbroker.cleverquantity=true
torque.manager.useCache = true
Re: IDBroker /ID_TABLE problem
Posted by Scott Eade <se...@backstagetech.com.au>.
Marc,
The problem is that your ID_TABLE is empty - it needs to have a row that
defines the ids it should allocate to MY_TABLE.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com
On 13/01/2003 9:47 AM, "Marc Lustig" <ma...@marclustig.com> wrote:
> Hi,
> I have just set the fields of my BO and tried to save() to create a new row.
> Torque complains:
>
> java.lang.reflect.InvocationTargetException:
> org.apache.torque.TorqueException: The table MY_TABLE does not have a proper
> entry in the ID_TABLE at
> org.apache.torque.oid.IDBroker.selectRow(IDBroker.java:803) at
> org.apache.torque.oid.IDBroker.storeIDs(IDBroker.java:665) at
> org.apache.torque.oid.IDBroker.getNextIds(IDBroker.java:441) at
> org.apache.torque.oid.IDBroker.getIdAsBigDecimal(IDBroker.java:329) at
> org.apache.torque.util.BasePeer.doInsert(BasePeer.java:702) at
>
> My schema is set to defaultIdMethod="idbroker".
> My id_table is completely empty.
> What's the problem here?
> Can anybody give me a hint?
>
> Marc
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>