aspose file tools*
The moose likes Object Relational Mapping and the fly likes Migrating Toplink/ADF application to MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Migrating Toplink/ADF application to MySQL" Watch "Migrating Toplink/ADF application to MySQL" New topic
Author

Migrating Toplink/ADF application to MySQL

Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 81
We have a J2EE application based on Toplink (10.1.3.5) / ADF / Oracle db. We tried to migrate it to MySql. We slightly changed data structure (IDs, some data types) and succesfully migrated data from Oracle to MySql. We even started the application, but we are stuck at some strange toplink error:

[TOPLINK-7197] (Oracle TopLink - 10g Release 3 (10.1.3.5.0) (Build 090715)): oracle.toplink.exceptions.ValidationException
Exception Description: Exception calculating changes. Primary Key can not be set to null.

We searched in code and found out the source of the problem - method hasChanges() in UnitOfWork object.
The problem started when we succesfully inserted new record to database (via form) and tried to return from form to list of records.

Does anybody have any experience with migrating Toplink/ADF application to MySql ? Please share your experience.

Thanks.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
What form of sequencing are you using? Did you switch to IDENTITY sequencing with MySQL? This has very different semantics, as you do not get the Id assigned until after the insert, so it is not available after the persist call.

This may be triggering your application to be incorrectly changing the Id of an object.

Try switching to TABLE sequencing, as this allows the pre-allocation of the Id, so would be more similar to Oracle. In general I would never recommend IDENTITY sequencing, as it is much less efficient as it cannot pre-allocate values.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Jiri Nejedly
Ranch Hand

Joined: Oct 22, 2002
Posts: 81
On Oracle we used sequence - "Use Native Sequencing" option in Toplink descriptor.
When switching to MySQL platform, the "Use Native Sequencing" became unavailable.
We set the first choice - Use Deafult Sequence Table (?)
Every table used has id ... NOT NULL AUTO_INCREMENT

There's no such choice as 'Identity sequencing' in TL descriptor.

J.N.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
If you have specified TABLE sequencing and are using an AUTO_INCREMENT column that is probably the problem.

Remove the AUTO_INCREMENT.

IDENTITY is the JPA terminology, in TopLink API this is native sequencing. I don't think 10.1.3 supported identity sequencing on MySQL, so you would need to use table sequencing or upgrade to EclipseLink (TopLink 11g).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Migrating Toplink/ADF application to MySQL