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