Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-485
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-485
Summary: DYNAMIC_PREPARE and @@identity
Type: Bug
Status: Unassigned
Priority: Major
Project: Hibernate2
Components:
core
Assignee:
Reporter: Richard Scranton
Created: Thu, 20 Nov 2003 1:22 PM
Updated: Thu, 20 Nov 2003 1:22 PM
Description:
Using the Sybase jConnect jdbc driver version 4.5 or 5.5, if the connection property DYNAMIC_PREPARE is set to "true", "select @@identity" will always return a "0". This is an artifact of the Sybase implementation of prepared statements. Statements compiled at the server become stored procedures marked by the "DYN" token, and appear named as dyn100, dyn101, etc in the
captured TDS stream. The value of @@identity is lost at the end of a procedure, so a sequence of prepared statements like:
insert into Yadda (val1,val2) values ( 1,2 )
select @@identity
will execute as expected when DYNAMIC_PREPARE is false. If it is set to true, the statement "select @@identity" will return "0". Sybase suggests something like this workaround to get the expected behavior:
String nl=System.getProperty("line.separator");
PreparedStaement ps=conn.prepareStatement(
"insert into Yadd (val1,val2) values ( 1,2 )"
+ nl
+ "select @@identity");
Leaving DYNAMIC_PREPARE set false gives away throughput if the queries being sent and parsed are of significant size. TDS dumps show they are being sent and parsed with each invocation. Setting DYNAMIC_PREPARE to true allows reuse of the parsed queries.
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|