gdamour 2005/09/13 09:05:00
Modified: modules/pkgen-builder/src/java/org/openejb/deployment/pkgen
PKGenBuilder.java TranQLPKGenBuilder.java
Log:
GERONIMO-1004 SequenceTablePrimaryKeyGenerator transaction handling is broken
(Tranql)
As pointed out by David J, a TransactionManager needs to be passed to
SequenceTablePrimaryKeyGenerator in order to suspend and resume in-flight
transactions while retrieving the next ids.
Revision Changes Path
1.2 +4 -2
openejb/modules/pkgen-builder/src/java/org/openejb/deployment/pkgen/PKGenBuilder.java
Index: PKGenBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/pkgen-builder/src/java/org/openejb/deployment/pkgen/PKGenBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PKGenBuilder.java 7 Jul 2005 21:37:08 -0000 1.1
+++ PKGenBuilder.java 13 Sep 2005 13:05:00 -0000 1.2
@@ -48,6 +48,8 @@
package org.openejb.deployment.pkgen;
import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
import org.tranql.pkgenerator.PrimaryKeyGenerator;
import org.tranql.ql.QueryException;
import org.openejb.xbeans.pkgen.EjbKeyGeneratorType;
@@ -67,5 +69,5 @@
* @version $Revision$ $Date$
*/
public interface PKGenBuilder {
- PrimaryKeyGenerator configurePKGenerator(EjbKeyGeneratorType config,
DataSource dataSource, Class pkClass, EARContext earContext) throws
DeploymentException, QueryException;
+ PrimaryKeyGenerator configurePKGenerator(EjbKeyGeneratorType config,
TransactionManager tm, DataSource dataSource, Class pkClass, EARContext
earContext) throws DeploymentException, QueryException;
}
1.2 +6 -3
openejb/modules/pkgen-builder/src/java/org/openejb/deployment/pkgen/TranQLPKGenBuilder.java
Index: TranQLPKGenBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/pkgen-builder/src/java/org/openejb/deployment/pkgen/TranQLPKGenBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TranQLPKGenBuilder.java 7 Jul 2005 21:37:08 -0000 1.1
+++ TranQLPKGenBuilder.java 13 Sep 2005 13:05:00 -0000 1.2
@@ -51,6 +51,8 @@
import java.util.HashMap;
import javax.management.ObjectName;
import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
import org.tranql.pkgenerator.PrimaryKeyGeneratorDelegate;
import org.tranql.pkgenerator.SQLPrimaryKeyGenerator;
import org.tranql.pkgenerator.PrimaryKeyGenerator;
@@ -98,12 +100,13 @@
* be prepared to acquire a new data source after deserialization.
*
* @param config The XMLBeans object tree representing the key-generator
element in the XML document
+ * @param tm The TransactionManager that the key generator should use,
if needed
* @param dataSource The JDBC data source that the key generator should
use
* @param pkClass The key generator should return IDs of this type
* @param earContext Used by the key generator when it needs to register
a GBean for any reason
* @return The configured PrimaryKeyGenerator
*/
- public PrimaryKeyGenerator configurePKGenerator(EjbKeyGeneratorType
config, DataSource dataSource, Class pkClass, EARContext earContext) throws
DeploymentException, QueryException {
+ public PrimaryKeyGenerator configurePKGenerator(EjbKeyGeneratorType
config, TransactionManager tm, DataSource dataSource, Class pkClass, EARContext
earContext) throws DeploymentException, QueryException {
//todo: Handle a PK Class with multiple fields?
if(config.isSetCustomGenerator()) {
EjbCustomGeneratorType custom = config.getCustomGenerator();
@@ -135,7 +138,7 @@
String tableName = seq.getTableName();
String sequenceName = seq.getSequenceName();
int batchSize = seq.getBatchSize();
- SequenceTablePrimaryKeyGenerator generator = new
SequenceTablePrimaryKeyGenerator(dataSource, tableName, sequenceName,
batchSize);
+ SequenceTablePrimaryKeyGenerator generator = new
SequenceTablePrimaryKeyGenerator(tm, dataSource, tableName, sequenceName,
batchSize);
return generator;
} else if(config.isSetAutoIncrementTable()) {
EjbAutoIncrementTableType auto = config.getAutoIncrementTable();