Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Mysql Mapping

Hi, I'm using Mysql as platform database and I have some problems wih Id mappings. In some classes the Long  field with Id annotation are generated as Blob instead of BigInt.
The Id fields are like this.

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID_PK")
    private Long id;

Also try to annotate the getters and the behavior is the same.

This mapping error generate this error on runtime when I try to load something from the entity:

Exception [EclipseLink-3001] (Eclipse Persistence Services - 1.1 (Build SNAPSHOT - 20080822)): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [2], of class [class java.lang.Long], could not be converted to [class [B].
    at org.eclipse.persistence.exceptions.ConversionException.couldNotBeConverted(
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToByteArray(
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(
    at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromRow(
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromExpression(


Inspecting the stacktrace I found in the class  MySQLPlatform that the id field is being mapped as Byte[]
    fieldTypeMapping.put(Byte[].class, new FieldTypeDefinition("BLOB", 64000));

Any idea?

Mysql driver 5.0.8 or 5.1.4.
Mysql db version 5.0.45.
OS: osx 10.5 or windows XP SP2

Thanks in advance.

Back to the top