dev@glassfish.java.net

Re: SQLAnyhwhere: Is it OK to "fake" a sequence?

From: Lance J. Andersen <Lance.Andersen_at_Sun.COM>
Date: Wed, 10 Jan 2007 10:23:55 -0500

While, i am still not an expert on Toplink Essentials codeline yet, my
take is that you are reading too much into the method names.


Looking at this and the other platforms, this to me is just the way to
access identity/sequences... etc.


So I do not see you are faking a sequence, just providing the correct
plumbing in order to provide the support required for the given
platform, in this case, SQL Anywhere, to return the auto-generated
values, which in this case is done via an identity column.

Markus KARG wrote:
> Tom Ware schrieb:
>> Hi Markus,
>>
>> Can you point me to the code that is "faking" a sequence in your
>> platform.
>>
>> -Tom
> Excerpt from my SQLAnywherePlatform implementation:
>
> @Override
> public final boolean supportsNativeSequenceNumbers() {
> return true;
> }
>
> @Override
> public final boolean shouldNativeSequenceAcquireValueAfterInsert() {
> return true;
> }
>
> @Override
> public final ValueReadQuery buildSelectQueryForNativeSequence() {
> return new ValueReadQuery("SELECT @@identity");
> }
>
> @Override
> public final void printFieldIdentityClause(final Writer writer)
> throws ValidationException {
> try {
> writer.write(" DEFAULT AUTOINCREMENT");
> } catch (final IOException ioException) {
> throw ValidationException.fileError(ioException);
> }
> }
>
> That methods (all but one) have the word "nativeSequence" in their
> name. Since SQLAnyhwere does not have a SEQUENCE facility, this is a
> fake: It just reuses the IDENTITY column as a generator. At least the
> entity-persistence-tests that always complained about missing
> generator support are no more complaining now. So for me, it looks
> like a fake. Isn't it?
>
> Have Fun
> Markus
>>
>> Lance J. Andersen wrote:
>>
>>> Hi Markus,
>>>
>>> Perhaps i missed it, can u explain why you feel you need to fake this?
>>>
>>> If the Database does not support SEQUENCE, i would not fake it.
>>>
>>> Having support for IDENTITY is enough.
>>>
>>> Once/IF ASA implements SEQUENCE then it is worth adding to ASA
>>> support in Toplink Essentials. Until then i would avoid adding this
>>> feature.
>>>
>>> regards
>>> Lance
>>>
>>> -lance
>>>
>>>
>>> Markus KARG wrote:
>>>
>>>
>>>> Tom,
>>>>
>>>> another open question: As you know, I have "faked" support for SQL
>>>> sequences by using IDENTITY columns. Actually, for JPA a SEQUENCE
>>>> is not the same than an IDENTITY column. At least the
>>>> @GeneratedValue annotation lets the user decide whether SEQUENCE or
>>>> IDENTITY shall be used. So is my decision wrong? Shall I remove the
>>>> fake (then it should be removed from the SybasePlatform, too)? What
>>>> is the "political decision" for "faking features"?
>>>>
>>>> Thanks
>>>> Markus
>>>>
>>>
>>>
>>>
>>
>