Hi Pramod,
If you would like us to make the changes, feel free to enter a P3
issue in Issue Tracker. We will address it when we address the other P3
issues. Alternately, feel free to make and test the change yourself.
Thanks,
Tom
-------- Original Message --------
Subject: Re: Should not we also have fieldTypeMappings for byte[] and
char[]
Date: Thu, 26 Jan 2006 11:12:37 -0800
From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
To: Tom Ware <tom.ware_at_oracle.com>
CC: persistence_at_glassfish.dev.java.net, gordon.yorke_at_oracle.com
References: <20060112131715721.00000002780_at_gyorke-pc2>
<43D84B79.1070907_at_sun.com> <43D8FBF7.2040309_at_oracle.com>
Hi Tom
I am fine with you making the changes. I had one additional
observation. This has to do with ConversionManager.getObjectClass(Class
javaClass)
This method assumes that a byte[] would return isPrimitive() to be true.
This is invalid.
Thanks
Pramod
Tom Ware wrote:
> Hi Pramod,
>
> It looks to me like making the changes to add byte[] and char[] make
> sense. As long as your testing works for these changes that should be
> fine.
>
> Theoretically making the changes for int[], long[] etc.. to produce a
> Blob is also OK. Making these changes will require a great deal of
> interoperability testing to make sure JDBC handles these mappings for
> the majority of our supported databases.
>
> -Tom
>
> Pramod Gopinath wrote:
>
>> Hi Tom/Gordon
>>
>> In the method buildFieldTypes() of the database platforms we
>> currently have definitions for Byte[] and Character[]. Shouldn't we
>> also have definitions for byte[] and char[]. So currently if the
>> user defines a field that is byte[] we are incorrectly creating a
>> VARCHAR(255) field for it.
>>
>> For e.g. looking at DB2Platform.buildFieldTypes() we currently have
>>
>>
>> fieldTypeMapping.put(Byte[].class, new
>> FieldTypeDefinition("BLOB", 64000));
>> fieldTypeMapping.put(Character[].class, new
>> FieldTypeDefinition("CLOB", 64000));
>>
>> should we not also have
>>
>> fieldTypeMapping.put(byte[].class, new
>> FieldTypeDefinition("BLOB", 64000));
>> fieldTypeMapping.put(char[].class, new
>> FieldTypeDefinition("CLOB", 64000));
>>
>>
>>
>> Also in EJBAnnotationsProcessor.processLob() we are currently setting
>> the fields to be of type java.sql.Clob and java.sql.Blob but none of
>> the database platforms have any definitions for java.sql.Blob or Clob.
>> So there is a bug currently, where a user field defined as
>> @Lob
>> public byte[] getPic() { return pic; }
>>
>> gets created as VARCHAR(255) which is wrong. This should be created
>> as BLOB(<some size>). I am using DERBY database.
>>
>>
>> Once the above change (byte[] and char[] is made) the code in
>> EJBAnnotationsProcessor.processLob would change to read
>>
>> if (MetadataHelper.isValidClobType(referenceClass)) {
>> mapping.setFieldClassification(char[].class); }
>> else if (MetadataHelper.isValidBlobType(referenceClass)) {
>> mapping.setFieldClassification(byte[].class);
>>
>>
>> Additionally the code does not account for arrays of other primitive
>> types like int[], long[] ... etc. Should they not be treated as Blobs
>> too ?
>>
>>
>> What do U guys think ?
>>
>> Thanks
>> Pramod
>>
>>
>>
>>
>
--
Tom Ware
Principal Software Engineer
Oracle Canada Inc.
Direct: (613) 783-4598
Email: tom.ware_at_oracle.com