Re: Problem w/ SequenceManagerTransientImpl in 1.0.4

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi,

Armin Waibel wrote:

>> We encountered a problem with the SequenceManagerTransientImpl.  We have
>> two objects that are related; bank account has a bank on it.  A key to
>> the bank account table has a custom FieldConversion implementation for
>> encryption/decryption associated with it.  When we refresh the
>> references on a new bank account, OJB goes to retrieve the bank and uses
>> SequenceManagerTransientImpl to initialize any null keys on bank account
>> with a unique value.  However, after SequenceManagerTransientImpl
>> returns a long > 1000, AbstractSequenceManager calls the sqlToJava
>> method on the custom FieldConversion (in the getUniqueLong method).  The
>> custom FieldConversion bombs, because it's being asked to unencrypt and
>> already unencrypted value.  So, we overrode getUniqueValue in
>> SequenceManagerTransientImpl as follows...
>>     public Object getUniqueValue(FieldDescriptor field) throws
>> SequenceManagerException
>>     {
>>         return field.getJdbcType().sequenceKeyConversion(new
>> Long(getUniqueLong(field)));
>>         // perform a sql to java conversion here, so that clients do
>>         // not see any db specific values
>>         // abyrne commented out: result =
>> field.getFieldConversion().sqlToJava(result);
>>         // abyrne commented out: return result;
>>     }
>> We would appreciate your feedback on whether or not this seems
>> problematic.  
> 
> The conversion is already done in the super-class
> http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/sequence/AbstractSequenceManager.java?view=markup 
> 
> See method #getUniqueValue(...)
> This method is called by OJB to lookup the next key.
> 

Damn stupid! Sorry I don't carefully read your question (seems responses 
written after midnight doesn't contain useful information ;-)).

I think it could be problematic to comment out the field conversion. For 
example, if someone use a long-->String field conversion (with some 
other modification) for the PK field it's necessary to convert the 
temporary values.

Isn't it possible to differ these temporary values in your field 
conversion implementation?

Would it be useful to make SequenceManagerTransient pluggable, e.g. in 
the jdbc-connection-descriptor? In this case you could easily use a 
modified version.

regards,
Armin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.