Skip to main content

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

Hi, my fault. The two classes with the problem contains a field with @PrimaryKeyJoinColumn and the referenced class not contain the Id field with the type Long but the class. Changing the class by Long works fine.

Thanks.

On 25-08-2008, at 10:16, Tom Ware wrote:

I am surprised your Long is being mapped as a Blob. The field type mappings actually map a Long as a BIGINT.

You should be able to see the table generation syntax by turning on logging. Add the property: eclipselink.logging.level=FINEST to your persistence unit.

You can also have the table creation SQL generated to a file by adding the following two properties to your persistence unit:

eclipselink.create-ddl-jdbc-file-name=<filename>
eclipselink.ddl-generation.output-mode=sql-script
- the value "both" for this setting will allow you to both go the the DB and get the sQL script

I am wondering if EclipseLink is detecting that MySQL is being used in your application. Try setting the following property in your persistence unit and see if it helps:

eclipselink.target-database=MySQL

-Tom

Alejandro de Brito Fontes wrote:
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. <http://5.1.4.>
Mysql db version 5.0.45. <http://5.0.45.>
OS: osx 10.5 or windows XP SP2
Thanks in advance.
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top