db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: Expected behavior of identity_val_local()?
Date Thu, 02 Feb 2006 21:10:36 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
This is DERBY-439 that has been marked as duplicate of <a
 href="http://issues.apache.org/jira/browse/DERBY-353">DERBY-353</a>
and fixed in trunk. (10.2 release) Fix could be back-ported to 10.1, if
you have the itch and need.<br>
<br>
Satheesh<br>
<br>
Justin Patterson wrote:<br>
<blockquote cite="mid43E25A77.1000904@pattersonhouse.net" type="cite">I'm
working with Hibernate 3 and Derby 10.1.2.1 and some bad things started
happening (I just ported to Derby from One$DB).&nbsp; I traced it back to a
behavior in Derby and I'm wondering if it's the expected behavior or
not.&nbsp; I've simplified the condition below.
  <br>
  <br>
CREATE TABLE test1 (
  <br>
&nbsp;id INTEGER GENERATED ALWAYS AS IDENTITY
  <br>
);
  <br>
  <br>
INSERT INTO test1 (id) VALUES (default);
  <br>
VALUES identity_val_local();
  <br>
  <br>
DROP TABLE test1;
  <br>
  <br>
This mimics what Hibernate is doing in my application.&nbsp; I would expect
that identity_val_local() would return '1' here, but instead it's set
to NULL.&nbsp; It seems to be related to the fact that there's only one
column and it's the identity column.&nbsp; The reason that I say this is
because, if I create a table with another column, and insert a record
into it with the 'id' defaulted either explicitly or implicitly
(through omission), it works as I would expect.
  <br>
  <br>
CREATE TABLE test2 (
  <br>
&nbsp;id INTEGER GENERATED ALWAYS AS IDENTITY,
  <br>
&nbsp;dummy SMALLINT
  <br>
);
  <br>
  <br>
INSERT INTO test2 (id,dummy) VALUES (default,8);
  <br>
VALUES identity_val_local();
  <br>
INSERT INTO test2 (dummy) VALUES (8);
  <br>
VALUES identity_val_local();
  <br>
  <br>
DROP TABLE test2;
  <br>
  <br>
In this case it returns first '1' and then '2'.
  <br>
  <br>
I saw that there were some conditions under which the value returned by
identity_val_local() was not affected, but I don't think that a table
with only one column that's the identity column was one of those cases.
  <br>
  <br>
Any advice is greatly appreciated.
  <br>
  <br>
Thanks,
  <br>
-Justin
  <br>
  <br>
  <br>
  <br>
</blockquote>
</body>
</html>


Mime
View raw message