Migrating MySQL to Oracle & Java Persistence API

I’ve had a project where I need to migrate from using MySQL to Oracle going on at the moment.

Oracle uses Sequencers, but fortunately the Java code had been implemented (I believe) using Java Persistence API. Hence the annotations need changing to:

@GeneratedValue(generator=”LocalSeqName”)
@SequenceGenerator(name=”LocalSeqName”,sequenceName=”DatabaseSequenceName”,allocationSize=1)

Provided the generator attribute on the 1st line matches the name on the second, and then the sequence name attribute matches the sequencer name in the database. The allocationSize is also required if the increment size is specified in the database.

Once this had been updated for all necessary classes, upon deploying to the GlassFish server (v2 I believe), I encountered this error:

Exception Description: An exception was thrown while loading class <myclassname>:  to check whether it implements @Entity, @Embeddable, or @MappedSuperclass

After much searching around, it appears its a bug in GlassFish v2. To solve it, restart the application server, and then redeploy the application. (Much thanks to: http://screwdriver.felk.cvut.cz/mediawiki/index.php/J2ee_troubleshooting)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s