I'm sorry, this is not supported.
May I ask what is your use case? IDENTITY and AUTO_GENERATE are
basically the same, why do you need two such columns?
Regards,
Thomas
Ah, the old, “write good code” argument. J
I was migrating code which previously did things a little differently (previously it was JDO so the column, which is now an IDENTITY, was just an undefined object reference, handled in an undefined way by the underlying implementation) and this was a literal translation of that code which maintained an AUTO_GENERATE column separately since the primary key couldn’t be relied upon to work exactly that way in JDO.
Yesterday I refactored the code to remove the extra AUTO_GENERATE column and make use of the PRIMARY KEY IDENTITY column which produces the identical result, as you noted.
So it’s fair to use the “write good code, dummie” argument I think. J
Dave
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1209 / Virus Database: 1500/3544 - Release Date: 04/01/11
Thanks! H2 internally uses SCOPE_IDENTITY for getGeneratedKeys(), and
changing this would be quite some work. Therefore I would like to
understand how important this issue is.
Regards,
Thomas
I meant to say, previously, that it’s not important, at least not for this use case, since the two auto-generate columns were identical, the two can logically be replaced by one, which is better code in general (just required a minor refactoring which should have been done anyway).
The only use case I could think of (and I’m not promoting this use case as important, myself) would be if you configured an identity and also an auto-generate that doesn’t follow the typical 1..2..3..4 sequence.
So if I were you I would *not* worry about this request unless you hear real use-case requirements from other users. I’m sure there are a hundred better things to focus on.
A note in the docs might be nice though, since JDBC, and (in my case) Spring both expressly support this feature. Perhaps even an unsupported exception if the user calls Statement.execute(sql, stringArrayOfAutoGenColumnNames) with more than one column name for auto generation. This way we could easily see that it’s not supported rather than troubleshooting what appears, at first glance, to be a bug.
Thanks,
David
From: h2-da...@googlegroups.com [mailto:h2-da...@googlegroups.com] On Behalf Of Thomas Mueller
Sent: Tuesday, April 05, 2011 12:54 PM
To: h2-da...@googlegroups.com
Subject: Re: getGeneratedKeys() returns only "SCOPE_IDENTITY()" when multiple auto generated columns exist
Hi,
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1209 / Virus Database: 1500/3550 - Release Date: 04/04/11
I will add a feature request for "Support INSERT INTO / UPDATE / MERGE
... RETURNING to retrieve the generated key(s)."
Regards,
Thomas