[jira] [Assigned] (TORQUE-357) Implement IDGenerator using java.sql.Statement.getGeneratedKeys
[ https://issues.apache.org/jira/browse/TORQUE-357?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Vandahl reassigned TORQUE-357: - Assignee: Thomas Vandahl > Implement IDGenerator using java.sql.Statement.getGeneratedKeys > --- > > Key: TORQUE-357 > URL: https://issues.apache.org/jira/browse/TORQUE-357 > Project: Torque > Issue Type: New Feature > Components: Runtime >Affects Versions: 4.0 >Reporter: Thomas Vandahl >Assignee: Thomas Vandahl >Priority: Major > > Avoid separate database roundtrip for JDBC drivers supporting > java.sql.Statement.getGeneratedKeys -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org
svn commit: r1850586 - in /db/torque/torque4/trunk/torque-runtime/src: main/java/org/apache/torque/ main/java/org/apache/torque/adapter/ main/java/org/apache/torque/oid/ main/java/org/apache/torque/ut
Author: tv Date: Sun Jan 6 18:46:35 2019 New Revision: 1850586 URL: http://svn.apache.org/viewvc?rev=1850586&view=rev Log: TORQUE-357: Add feature to use JDBC-3.0-Statement.getGeneratedKeys() if the driver supports it. Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractAdapter.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/Adapter.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/AbstractIdGenerator.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDGeneratorFactory.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IdGenerator.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/BasePeerImplTest.java Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1850586&r1=1850585&r2=1850586&view=diff == --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java Sun Jan 6 18:46:35 2019 @@ -372,6 +372,17 @@ public class TorqueInstance log.debug("Adding " + adapterKey + " -> " + handle + " as Adapter"); +// try to get additional meta data from the driver +try (Connection con = database.getDataSourceFactory() +.getDataSource().getConnection()) +{ +AdapterFactory.setCapabilities(con, adapter); +} +catch (SQLException e) +{ +log.debug("Could not get database meta data from JDBC"); +} + // add Id generators for (IDMethod idMethod : IDGeneratorFactory.ID_GENERATOR_METHODS) { Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractAdapter.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractAdapter.java?rev=1850586&r1=1850585&r2=1850586&view=diff == --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractAdapter.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AbstractAdapter.java Sun Jan 6 18:46:35 2019 @@ -20,6 +20,7 @@ package org.apache.torque.adapter; */ import java.sql.Connection; +import java.sql.DatabaseMetaData; import java.sql.SQLException; import org.apache.torque.TorqueException; @@ -51,6 +52,9 @@ public abstract class AbstractAdapter im /** Serial version UID. */ private static final long serialVersionUID = 1L; +/** A flag to determine whether Statement#getGeneratedKeys() should be used. */ +private boolean useGetGeneratedKeys = false; + /** * Empty constructor. */ @@ -280,4 +284,26 @@ public abstract class AbstractAdapter im { return false; } + +/** + * whether Statement#getGeneratedKeys() should be used. + * + * @return a boolean value + */ +public boolean useGetGeneratedKeys() +{ +return this.useGetGeneratedKeys; +} + +/** + * Update static capabilities of the adapter with actual + * readings based on the JDBC meta-data + * + * @param dmd database meta data + * @throws SQLException if there are problems getting the JDBC meta data + */ +public void setCapabilities(DatabaseMetaData dmd) throws SQLException +{ +this.useGetGeneratedKeys = dmd.supportsGetGeneratedKeys(); +} } Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/Adapter.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/Adapter.java?rev=1850586&r1=1850585&r2=185058
svn commit: r1850588 - /db/torque/torque4/trunk/pom.xml
Author: tv Date: Sun Jan 6 18:47:56 2019 New Revision: 1850588 URL: http://svn.apache.org/viewvc?rev=1850588&view=rev Log: testcontainer 1.0.8-SNAPSHOT makes all test fail Modified: db/torque/torque4/trunk/pom.xml Modified: db/torque/torque4/trunk/pom.xml URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/pom.xml?rev=1850588&r1=1850587&r2=1850588&view=diff == --- db/torque/torque4/trunk/pom.xml (original) +++ db/torque/torque4/trunk/pom.xml Sun Jan 6 18:47:56 2019 @@ -409,7 +409,7 @@ org.apache.fulcrum fulcrum-testcontainer -1.0.8-SNAPSHOT +1.0.7 test - To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org
svn commit: r1850589 - /db/torque/torque4/trunk/torque-test/pom.xml
Author: tv Date: Sun Jan 6 18:48:34 2019 New Revision: 1850589 URL: http://svn.apache.org/viewvc?rev=1850589&view=rev Log: Use properties for JDBC driver versions Modified: db/torque/torque4/trunk/torque-test/pom.xml Modified: db/torque/torque4/trunk/torque-test/pom.xml URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/pom.xml?rev=1850589&r1=1850588&r2=1850589&view=diff == --- db/torque/torque4/trunk/torque-test/pom.xml (original) +++ db/torque/torque4/trunk/torque-test/pom.xml Sun Jan 6 18:48:34 2019 @@ -47,6 +47,12 @@ abort +10.14.2.0 +2.3.1 +1.2.7 +8.0.13 +10.2.0.3.0 +9.1-901.jdbc4 @@ -620,7 +626,7 @@ derby org.apache.derby - 10.8.2.2 + ${torque.test.derby.version} test @@ -633,7 +639,7 @@ derby org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -643,7 +649,7 @@ derby org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -685,7 +691,7 @@ derby org.apache.derby - 10.8.2.2 + ${torque.test.derby.version} test @@ -698,7 +704,7 @@ derby org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -708,7 +714,7 @@ derby org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -749,7 +755,7 @@ hsqldb org.hsqldb - 2.3.1 + ${torque.test.hsqldb.version} test @@ -762,7 +768,7 @@ hsqldb org.hsqldb -2.3.1 +${torque.test.hsqldb.version} @@ -772,7 +778,7 @@ hsqldb org.hsqldb -2.3.1 +${torque.test.hsqldb.version} @@ -814,7 +820,7 @@ hsqldb org.hsqldb - 2.2.8 + ${torque.test.hsqldb.version} test @@ -827,7 +833,7 @@ hsqldb org.hsqldb -2.4.1 +${torque.test.hsqldb.version} @@ -837,7 +843,7 @@ hsqldb org.hsqldb -2.4.1 +${torque.test.hsqldb.version} @@ -874,7 +880,7 @@ derbyclient org.apache.derby - 10.8.2.2 + ${torque.test.derby.version} test @@ -887,7 +893,7 @@ derbyclient org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -897,7 +903,7 @@ derbyclient org.apache.derby -10.8.2.2 +${torque.test.derby.version} @@ -911,7 +917,6 @@ false -8.0.13 mysql native bookstore @@ -995,7 +1000,7 @@ jtds net.sourceforge.jtds - 1.2.7 + ${torque.test.mssql.version} test @@ -1008,7 +1013,7 @@ jtds net.sourceforge.jtds -1.2.7 +${torque.test.mssql.version} @@ -1018,7 +1023,7 @@ jtds net.sourceforge.jtds -1.2.7 +${torque.test.mssql.version} @@ -1055,7 +1060,7 @@ ojdbc14 com.oracle - 10.2.0.3.0 + ${torque.test.oracle.version} test @@ -1068,7 +1073,7 @@ ojdbc14 com.oracle -10.2.0.3.0 +${torque.test.oracle.version} @@ -1078,7 +1083,7 @@ ojdbc14 com.oracle -10.2.0.3.0 +${torque.test.oracle.version} @@ -1115,7 +1120,7 @@ postgresql postgre
[jira] [Resolved] (TORQUE-357) Implement IDGenerator using java.sql.Statement.getGeneratedKeys
[ https://issues.apache.org/jira/browse/TORQUE-357?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thomas Vandahl resolved TORQUE-357. --- Resolution: Fixed Fix Version/s: 4.1 Added feature to read support from JDBC driver and use it if it exists. > Implement IDGenerator using java.sql.Statement.getGeneratedKeys > --- > > Key: TORQUE-357 > URL: https://issues.apache.org/jira/browse/TORQUE-357 > Project: Torque > Issue Type: New Feature > Components: Runtime >Affects Versions: 4.0 >Reporter: Thomas Vandahl >Assignee: Thomas Vandahl >Priority: Major > Fix For: 4.1 > > > Avoid separate database roundtrip for JDBC drivers supporting > java.sql.Statement.getGeneratedKeys -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org
svn commit: r1850591 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java
Author: tv Date: Sun Jan 6 19:00:34 2019 New Revision: 1850591 URL: http://svn.apache.org/viewvc?rev=1850591&view=rev Log: Derby supports getGeneratedKeys() but does not report it via JDBC, so we override the JDBC response Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java?rev=1850591&r1=1850590&r2=1850591&view=diff == --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java Sun Jan 6 19:00:34 2019 @@ -163,6 +163,17 @@ public class DerbyAdapter extends Abstra } /** + * Derby supports this feature but does not report it via JDBC + * + * @see org.apache.torque.adapter.AbstractAdapter#useGetGeneratedKeys() + */ +@Override +public boolean useGetGeneratedKeys() +{ +return true; +} + +/** * Build Derby-style query with limit or offset. * The resulting query may look like this: * - To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org For additional commands, e-mail: torque-dev-h...@db.apache.org
Re: svn commit: r1850588 - /db/torque/torque4/trunk/pom.xml
Sorry Thomas - it looked like it was working on my end :/ - Jeff On 1/6/19 1:47 PM, t...@apache.org wrote: > Author: tv > Date: Sun Jan 6 18:47:56 2019 > New Revision: 1850588 > > URL: http://svn.apache.org/viewvc?rev=1850588&view=rev > Log: > testcontainer 1.0.8-SNAPSHOT makes all test fail > > Modified: > db/torque/torque4/trunk/pom.xml > > Modified: db/torque/torque4/trunk/pom.xml > URL: > http://svn.apache.org/viewvc/db/torque/torque4/trunk/pom.xml?rev=1850588&r1=1850587&r2=1850588&view=diff > == > --- db/torque/torque4/trunk/pom.xml (original) > +++ db/torque/torque4/trunk/pom.xml Sun Jan 6 18:47:56 2019 > @@ -409,7 +409,7 @@ > > org.apache.fulcrum > fulcrum-testcontainer > -1.0.8-SNAPSHOT > +1.0.7 > test > > > > > > - > To unsubscribe, e-mail: torque-dev-unsubscr...@db.apache.org > For additional commands, e-mail: torque-dev-h...@db.apache.org > signature.asc Description: OpenPGP digital signature