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.

    @Id
    @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(ConversionException.java:71)
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObjectToByteArray(ConversionManager.java:331)
    at org.eclipse.persistence.internal.helper.ConversionManager.convertObject(ConversionManager.java:138)
    at org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform.convertObject(DatasourcePlatform.java:151)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromRow(ObjectBuilder.java:1822)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.extractPrimaryKeyFromExpression(ObjectBuilder.java:1717)

.....

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