[teiid-issues] [JBoss JIRA] (TEIID-4596) Teiid does not return genereted keys after executeBatch

Juraj Duráni (JIRA) issues at jboss.org
Thu Dec 1 02:30:03 EST 2016


    [ https://issues.jboss.org/browse/TEIID-4596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13331963#comment-13331963 ] 

Juraj Duráni commented on TEIID-4596:
-------------------------------------

[~rareddy], the simplest test could look like follows:
{code:sql|title=MySQL55 Create table command}
CREATE TABLE ag (id integer AUTO_INCREMENT PRIMARY KEY, name varchar(10))
{code}
{code:sql|title=VDB DDL metadata}
CREATE FOREIGN TABLE ag (id integer PRIMARY KEY, name string) OPTIONS (UPDATABLE 'TRUE');
{code}
{code:java|title=Test}
Connection con = ...; // connect to your VDB
PreparedStatement ps = con.prepareStatement("INSERT INTO ag (name) VALUES (?)", Statement.RETURN_GENERATED_KEYS);
ps.setString(1, "name1");
ps.addBatch();
ps.setString(1, "name2");
ps.addBatch();
ps.setString(1, "name3");
ps.addBatch();
LOG.info("{}", ps.executeBatch());
ResultSet rs = ps.getGeneratedKeys();
// print the result set
{code}

Result of such test looks like:
{code:plain}
08:15:12.676 [main] INFO  sandbox.MainClass - [1, 1, 1]
--- result set start ---
columns:	
--- result set end ---
{code}

This behavior is hardcoded in StatementImpl [here|https://github.com/teiid/teiid/blob/15a1ec932cf54def24805de8b360d05e04e68b7b/client/src/main/java/org/teiid/jdbc/StatementImpl.java#L348] and [here|https://github.com/teiid/teiid/blob/15a1ec932cf54def24805de8b360d05e04e68b7b/client/src/main/java/org/teiid/jdbc/StatementImpl.java#L423].

> Teiid does not return genereted keys after executeBatch
> -------------------------------------------------------
>
>                 Key: TEIID-4596
>                 URL: https://issues.jboss.org/browse/TEIID-4596
>             Project: Teiid
>          Issue Type: Enhancement
>          Components: Documentation
>            Reporter: Juraj Duráni
>            Assignee: Ramesh Reddy
>            Priority: Minor
>
> Currently, Teiid does not return genereted keys after inserting value using PreparedStatement.executeBatch() method. JDBC ([4.1|http://download.oracle.com/otndocs/jcp/jdbc-4_1-mrel-spec/index.html]) does not require this :
> {quote}
> It is implementation-defined as to whether _getGeneratedKeys_ will return generated values  after invoking the _executeBatch_ method.
> {quote}
> However, it would be nice to have this behavior documented - https://teiid.gitbooks.io/documents/content/client-dev/JDBC_Support.html



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)



More information about the teiid-issues mailing list