-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate with Spring batch - select scope_identity() append
PostPosted: Tue Aug 06, 2013 1:06 am 
Newbie

Joined: Tue Aug 06, 2013 1:01 am
Posts: 1
I have a VO with the following fields -
Code:
HD_REC_ID
REC_TYP_CD
SRC_SYS_NM
SRC_TYP_CD
RCV_SYS_CD
JOB_STTS_CD
IDX_FILE_NM
IDX_FILE_LOC_TXT
XTRCT_DT
XTRCT_TM
DTL_REC_CNT
ATCH_CNT
ERR_MSG_TXT
PROC_MODE_CD
INVLD_HD_REC_TXT
CRT_TS


The annotations used are -
Code:
@Id
@Column(name = EntityConstants.HD_REC_ID)
@GeneratedValue(strategy = GenerationType.AUTO)
private int headerId;

@Generated(value = GenerationTime.INSERT)
@Column(name = EntityConstants.CRT_TS)
@Temporal(TemporalType.TIMESTAMP)
private Date creationTime;


Of these the first and last fields(HD_REC_ID and CRT_TS) are auto-generated. While inserting the value to DB, this is what i get on the console (edited console).
Code:
[8/5/13 15:22:12:666 IST] 00000063 SystemOut     O Hibernate: insert into T_HD_REC (ATCH_CNT, ERR_MSG_TXT, XTRCT_DT, XTRCT_TM, IDX_FILE_LOC_TXT, IDX_FILE_NM, INVLD_HD_REC_TXT, JOB_STTS_CD, PROC_MODE_CD, DTL_REC_CNT, REC_TYP_CD, RCV_SYS_CD, SRC_SYS_NM, SRC_TYP_CD) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) select scope_identity()
[8/5/13 15:22:13:046 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:100) 2013-08-05 15:22:13,045 -- WARN -- SQL Error: -199, SQLState: 42601
[8/5/13 15:22:13:047 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:101) 2013-08-05 15:22:13,046 -- ERROR -- DB2 SQL error: SQLCODE: -199, SQLSTATE: 42601, SQLERRMC: SELECT;;FOR <END-OF-STATEMENT> NOT ATOMIC
[8/5/13 15:22:13:047 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:100) 2013-08-05 15:22:13,047 -- WARN -- SQL Error: -516, SQLState: 26501
[8/5/13 15:22:13:048 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:101) 2013-08-05 15:22:13,047 -- ERROR -- DB2 SQL error: SQLCODE: -516, SQLSTATE: 26501, SQLERRMC: null
[8/5/13 15:22:13:048 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:100) 2013-08-05 15:22:13,048 -- WARN -- SQL Error: -518, SQLState: 07003
[8/5/13 15:22:13:049 IST] 00000063 SystemOut     O (JDBCExceptionReporter.java:101) 2013-08-05 15:22:13,048 -- ERROR -- DB2 SQL error: SQLCODE: -518, SQLSTATE: 07003, SQLERRMC: null


com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -199, SQLSTATE: 42601, SQLERRMC: SELECT;;FOR <END-OF-STATEMENT> NOT ATOMIC


Read up about SQL error codes here - http://pic.dhe.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z9.doc.codes%2Fsrc%2Ftpc%2Fn199.htm

Code:
-518
THE EXECUTE STATEMENT DOES NOT IDENTIFY A VALID PREPARED STATEMENT
-516
THE DESCRIBE STATEMENT DOES NOT SPECIFY A PREPARED STATEMENT
-199
ILLEGAL USE OF KEYWORD keyword. TOKEN token-list WAS EXPECTED


From what I understand, it is because the stmt select scope_identity() is appended without a preceeding semicolon. But I am not calling this anywhere. This error is happening while I am moving the POC we had created on SQL server to a DBA created database on DB2 9. This worked perfectly on SQL server. There was no select scope_identity() appended after the insert stmt logs while the application was on SQL server.

I am very new to both Hibernate and Spring(Batch). Sorry if this sounds silly to you... but surprisingly, I did not find anything of this type on the net... I checked this link out and got an idea about Identities. http://stackoverflow.com/questions/1920558/what-is-the-difference-between-scope-identity-identity-identity-and-ide

Any help would be appreciated... Thanks!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.