db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Zverina <dzl...@zverina.co.uk>
Subject Problem with MySQL id generation [Report + Solution]
Date Tue, 13 Jan 2004 16:34:12 GMT
The default distribution of Torque will not work with native id
generation when using a recent version of the mysql JDBC driver. You
will receive the following exception:

org.apache.torque.TorqueException: IdGenerator for table 'item' is null

This "feature" is related to following fragment of code in
src/java/org/apache/torque/TorqueInstance.java:
    642             String key = getDatabaseProperty(name, "driver");
    643             if (key == null || key.length() == 0)
    644             {
    645                 key = getDatabaseProperty(name, "adapter");
    646             }

This means that the old (driver) setting will override the more modern
(adapter) setting. This is probably bad idea. If the lines 642 and 645
were switched, everything should work fine.

Also it may be a good idea to insert the following line in
src/java/org/apache/torque/adapter/DBFactory.java after line 94:
         adapters.put("com.mysql.jdbc.Driver", DBMM.class);

There would be no harm in making sure that torque will work equally well
with the old and new mysql driver classes. The org.gjt driver is no
longer being worked on. Besides it will see of any other potential
gremlins of this nature.

And if you do not want to recompile torque yourself, you can use the
following workaround until the above patches are included. The
workaround simply forces the initialization to work correctly.

	DatabaseMap dm = Torque.getDatabaseMap("default");  // **make sure that
this has correct database name**
	dm.addIdGenerator("native",IDGeneratorFactory.create(DBFactory.create("mysql")));


ob questions:

Are there any good books on Torque? I think it's a brilliant tool but
the documentation is such a tough going!

And how often do patches get rolled into the distribution?

Thanks for all the good work,

David Zverina.








---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message