db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Waibel" <ar...@code-au-lait.de>
Subject Re: [PATCH] Sequence Support in Oracle
Date Sun, 12 Jan 2003 10:12:18 GMT
Damned seq prefix ;-)
Add your patch to CVS, many thanks for the
patch and the clear descriction of the problem.

regards,
Armin

----- Original Message -----
From: "Ron Gallagher" <rongallagher@bellsouth.net>
To: "OJB Dev Mailing List" <ojb-dev@jakarta.apache.org>
Sent: Sunday, January 12, 2003 3:03 AM
Subject: [PATCH] Sequence Support in Oracle


> All --
>
> I'm working with the HEAD revision from cvs, extracted from cvs
Saturday
> afternoon, and I'm trying to get the sequence manager to utilize
sequences
> that are defined in my repository.
>
> First, I added the following to my jdbc-connection-descriptor:
>   <jdbc-connection-descriptor platform="Oracle" ...>
>     <sequence-manager
>
className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImp
l"/>
>   </jdbc-connection-descriptor ...>
>
> I also configured a class to utilize a sequence:
>   <class-descriptor class="com.ge.ps.pdb.data.Bogus2Data"
table="BOGUS2">
>     <field-descriptor autoincrement="true" column="BOGUS2_ID" [SNIP]
> sequence-name="BOGUS2_ID"/>
>     <field-descriptor column="BOGUS2_NAME" [SNIP]/>
>   </class-descriptor>
>
> After doing this, I immediately got the following error:
>
>   "This feature is not supported by this implementation"
>
> The root cause of this was the absence of an implementation of the
> nextSequenceQuery method in
> org.apache.ojb.broker.platforms.PlatformOracleImpl.  I added an
> implementation for this method, and all is working fine for now.
Here's the
> implementation:
>
>     public String nextSequenceQuery(String sequenceName)
>     {
>         return "select " + sequenceName + ".nextval from dual";
>     }
>
> This implementation was copied straight from
> org.apache.ojb.broker.platforms.PlatformSapdbImpl.  I did not
implement
> createSequenceQuery or dropSequenceQuery since I don't need them in my
> situation.  However, should these methods also be implemented in
> org.apache.ojb.broker.platforms.PlatformOracleImpl to complete the
support?
> If so, the implementation that's found in
> org.apache.ojb.broker.platforms.PlatformSapdbImpl can be used as-is.
>
> Second question/problem...
>
> In the field-descriptor for the column "BOGUS2_ID", I initially
specified
> the full name of the sequence that I wanted to use ("SEQ_BOGUS2_ID").
> However, when it came time to get the next value from the sequence,
the name
> SEQ_SEQ_BOGUS2_ID was used instead.  A little searching found this in
the
> getUniqueId method in
> org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl:
>
>         // lookup sequence name
>         String sequenceName = SEQ_PREFIX +
> SequenceManagerHelper.buildSequenceName(getBrokerForClass(), field);
>
> If the sequence-name attribute is specified on the field-descriptor,
then
> SequenceManagerHelper.buildSequenceName will return the value as-is,
without
> modification.  So, in my case, SequenceManagerHelper.buildSequenceName
was
> returning SEQ_BOGUS2_ID, which is what I wanted.  However, the
getUniqueId
> method in SequenceManagerNextValImpl then added an extra prefix (SEQ_)
on to
> that, resulting in a sequence name of SEQ_SEQ_BOGUS2_ID, which is not
what I
> wanted.  It seems to me that the addition of the prefix by
> SequenceManagerNextValImpl.getUniqueId is unnecessary.  If
> SequenceManagerHelper.buildSequenceName finds a sequence-name on the
> field-descriptor, then that value should be used without modification.
That
> seems rather intuitive.  If there is no sequence-name specified on the
> field-descriptor, then the SequenceManagerHelper.buildSequenceName
method
> has extra logic to assemble a sequence name based on the table name of
the
> 'base' class.  If that logic is used to assemble the sequence name,
then it
> makes sense to append the "SEQ_" prefix at that point.
>
> I've attached updates to
org.apache.ojb.broker.platforms.PlatformOracleImpl
> and org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl to
> reflect the changes that I'm proposing.
>
> Ron Gallagher
> Atlanta, GA
> rongallagher@bellsouth.net
>
>
>


------------------------------------------------------------------------
--------


> --
> To unsubscribe, e-mail:
<mailto:ojb-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:ojb-dev-help@jakarta.apache.org>


Mime
View raw message