dev@glassfish.java.net

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

From: Markus KARG <markus.karg_at_gmx.net>
Date: Tue, 09 Jan 2007 21:35:17 +0100

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
>>>
>>
>>
>>
>