You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Sean Dockery <sd...@securac.net> on 2004/06/09 01:24:18 UTC
VARCHAR primarykey based upon OJB HighLow sequence in SQL Server 2000
Hello,
I am working with a content-heavy database application that uses OJB 1.0RC5
on SQL Server 2000. Because the content is part of the value-proposition
for customers to purchase our application, we would like a means of easily
identifying what (template) data came from us versus what data was created
by customers during their use of the application.
The hope is that we can have a primarykey of a VARCHAR type that contains
the hexadecimal format of the uniqueID issued by the HighLow sequence
manager implementation. For example, our customer records would begin at
$F0000000 for records that they create. Everything from $00000000 to
$EFFFFFFF would be part of our template data.
I have the source code to the version of OJB that we're using, but I am
unsure where I should make the change? Can I get away with just
sub-classing SequenceManagerHighLowImpl and overriding the getUniqueValue
method?
Here's the implementation that I had been thinking of...
public Object getUniqueValue(FieldDescriptor field) throws
SequenceManagerException {
Object value = super.getUniqueValue(field);
if ("VARCHAR".equals(field.getColumnType())) {
value = Long.toString(Long.parseLong(value.toString()), 16);
}
return value;
}
There are tables in the application which use the hi/lo manager for
legitimate integer unique ids; I don't want to interfere with that
operation.
Any comments?
Thanks in advance for your help.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: VARCHAR primarykey based upon OJB HighLow sequence in SQL Server 2000
Posted by Brian McCallister <mc...@forthillcompany.com>.
Glad to hear!
Sometimes I despair at some of the complexity having so many things
pluggable brings us, then you hear stories like this =)
-Brian
On Jun 10, 2004, at 1:23 AM, Sean Dockery wrote:
> For posterity, overriding the single method worked, but I had to do two
> other things:
>
> 1) Change the internal OJB descriptors such that the jdbc-type was a
> BIGINT
> instead of an INTEGER.
> 2) Changed the OJB_HL_SEQ schema such that the max_key column was
> created
> as a bigint instead of an int.
>
> I seeded the OJB_HL_SEQ table with a record having a max_key value of
> $F0000000 (in decimal form) and everything worked as expected. Far
> easier
> than I expected. :-)
>
> "Sean Dockery" <sd...@securac.net> wrote in message
> news:ca5ido$e47$1@sea.gmane.org...
>> Hello,
>>
>> I am working with a content-heavy database application that uses OJB
> 1.0RC5
>> on SQL Server 2000. Because the content is part of the
>> value-proposition
>> for customers to purchase our application, we would like a means of
> easily
>> identifying what (template) data came from us versus what data was
> created
>> by customers during their use of the application.
>>
>> The hope is that we can have a primarykey of a VARCHAR type that
>> contains
>> the hexadecimal format of the uniqueID issued by the HighLow sequence
>> manager implementation. For example, our customer records would
>> begin at
>> $F0000000 for records that they create. Everything from $00000000 to
>> $EFFFFFFF would be part of our template data.
>>
>> I have the source code to the version of OJB that we're using, but I
>> am
>> unsure where I should make the change? Can I get away with just
>> sub-classing SequenceManagerHighLowImpl and overriding the
>> getUniqueValue
>> method?
>>
>> Here's the implementation that I had been thinking of...
>>
>> public Object getUniqueValue(FieldDescriptor field) throws
>> SequenceManagerException {
>> Object value = super.getUniqueValue(field);
>> if ("VARCHAR".equals(field.getColumnType())) {
>> value = Long.toString(Long.parseLong(value.toString()), 16);
>> }
>> return value;
>> }
>>
>> There are tables in the application which use the hi/lo manager for
>> legitimate integer unique ids; I don't want to interfere with that
>> operation.
>>
>> Any comments?
>>
>> Thanks in advance for your help.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: VARCHAR primarykey based upon OJB HighLow sequence in SQL Server 2000
Posted by Sean Dockery <sd...@securac.net>.
For posterity, overriding the single method worked, but I had to do two
other things:
1) Change the internal OJB descriptors such that the jdbc-type was a BIGINT
instead of an INTEGER.
2) Changed the OJB_HL_SEQ schema such that the max_key column was created
as a bigint instead of an int.
I seeded the OJB_HL_SEQ table with a record having a max_key value of
$F0000000 (in decimal form) and everything worked as expected. Far easier
than I expected. :-)
"Sean Dockery" <sd...@securac.net> wrote in message
news:ca5ido$e47$1@sea.gmane.org...
> Hello,
>
> I am working with a content-heavy database application that uses OJB
1.0RC5
> on SQL Server 2000. Because the content is part of the value-proposition
> for customers to purchase our application, we would like a means of
easily
> identifying what (template) data came from us versus what data was
created
> by customers during their use of the application.
>
> The hope is that we can have a primarykey of a VARCHAR type that contains
> the hexadecimal format of the uniqueID issued by the HighLow sequence
> manager implementation. For example, our customer records would begin at
> $F0000000 for records that they create. Everything from $00000000 to
> $EFFFFFFF would be part of our template data.
>
> I have the source code to the version of OJB that we're using, but I am
> unsure where I should make the change? Can I get away with just
> sub-classing SequenceManagerHighLowImpl and overriding the getUniqueValue
> method?
>
> Here's the implementation that I had been thinking of...
>
> public Object getUniqueValue(FieldDescriptor field) throws
> SequenceManagerException {
> Object value = super.getUniqueValue(field);
> if ("VARCHAR".equals(field.getColumnType())) {
> value = Long.toString(Long.parseLong(value.toString()), 16);
> }
> return value;
> }
>
> There are tables in the application which use the hi/lo manager for
> legitimate integer unique ids; I don't want to interfere with that
> operation.
>
> Any comments?
>
> Thanks in advance for your help.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org