SAP Knowledge Base Article - Preview

2243859 - JPA - GenerationType.IDENTITY doesn't generate sequential ids - SAP SDK with jConnect 7.0 and 16.0

Symptom

  • GenerationType.IDENTITY is used for generating PrimaryKey values for one of the Entity.
  • A mismatch in generating values with JConnect 6.0 and JConnect 7.0 has been observed:
    • with JConnect 7.0 the values start with 0
    • with JConnect 6.0 it starts with 1
  • With JConnect 7 even if the table already has records with ID 1 to 6, inserting a new record results in an attempt to insert a record with ID 0 instead of 7.
  • This causes exceptions while inserting records into ASE.
  • Examples in the execution log:

JCONNECT 6: EL Fine]: sql: 2015-11-12 14:04:03.468--ClientSession(386040589)--Connection(1710422448)--Thread(Thread[main,5,main])--INSERT INTO Employee (DEG, ENAME) VALUES (?, ?) bind => [testdesignation, testemployee] [EL Finest]: query: 2015-11-12 14:04:03.47--ClientSession(386040589)--Thread(Thread[main,5,main])--Execute query ValueReadQuery(name="SEQ_GEN_IDENTITY" sql="SELECT @@IDENTITY") [EL Fine]: sql: 2015-11-12 14:04:03.47--ClientSession(386040589)--Connection(1710422448)--Thread(Thread[main,5,main])--SELECT @@IDENTITY [EL Finest]: sequencing: 2015-11-12 14:04:03.474--UnitOfWork(1422883946)--Thread(Thread[main,5,main])--assign sequence to the object (11 -> Employee [eid=null, ename=testemployee, deg=testdesignation]) [EL Finer]: transaction: 2015-11-12 14:04:03.483--ClientSession(386040589)--Connection(1710422448)--Thread(Thread[main,5,main])--commit transaction

JCONNECT 7: EL Fine]: sql: 2015-11-12 14:13:38.047--ClientSession(1891673045)--Connection(727273502)--Thread(Thread[main,5,main])--INSERT INTO Employee (DEG, ENAME) VALUES (?, ?) bind => [testdesignation, testemployee] [EL Finest]: query: 2015-11-12 14:13:38.051--ClientSession(1891673045)--Thread(Thread[main,5,main])--Execute query ValueReadQuery(name="SEQ_GEN_IDENTITY" sql="SELECT @@IDENTITY") [EL Fine]: sql: 2015-11-12 14:13:38.051--ClientSession(1891673045)--Connection(727273502)--Thread(Thread[main,5,main])--SELECT @@IDENTITY [EL Finest]: sequencing: 2015-11-12 14:13:38.056--UnitOfWork(382044126)--Thread(Thread[main,5,main])--assign sequence to the object (0 -> Employee [eid=null, ename=testemployee, deg=testdesignation]) [EL Finer]: transaction: 2015-11-12 14:13:38.065--ClientSession(1891673045)--Connection(727273502)--Thread(Thread[main,5,main])--commit transaction [EL Finest]: connection: 2015-11-12 14:13:38.067--ServerSession(1192108080)--Connection(727273502)--Thread(Thread[main,5,main])--Connection released to connection pool [default].


Read more...

Environment

  • SAP Software Developer Kit (SDK) 15.7
  • SAP Software Developer Kit (SDK) Adaptive Server Enterprise (ASE) 16.0
  • SAP Adaptive Server Enterprise (ASE) 15.7 and 16.0
  • JConnect for JDBC 7.0 and 16.0

Product

SAP Adaptive Server Enterprise 15.7 ; SAP Adaptive Server Enterprise 16.0 ; SAP Adaptive Server Enterprise SDK 16.0 ; Sybase Software Developer Kit 15.7

Keywords

DYNAMIC_PREPARE, PreparedStatement.getGeneratedKeys, JPA , KBA , BC-SYB-SDK , SDK , Problem

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP ONE Support launchpad (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.