• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL to Oracle

 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an J2EE application using hibernate with mysql,now I want to run it with Oracle with minimum changed to my code.

I understand I have to change my cgf files for changing the dialect,but is there any way to restrict changes to hbm files and java file (mapping class,if required to change).

for eg:- in mysql hbm I am using org.hibernate.id.IdentityGenerator for identity where as for Oracle I have to use sequence.

for this change I have to modify all hbm files,is there any way to do this by not modifying hbm files ?

I found one solution on web that says extend SequenceGenerator and override configure but I am not sure if
1) I can use it with same hbm file (Id generator)
2) Is it good idea to modify hibernate code?

Cheers
-Praful
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

for this change I have to modify all hbm files,is there any way to do this by not modifying hbm files

No. This isn't going to be very helpful now, but if you are going to use Hibernate across more than one type of database, its always a good idea to pick a key generation method that is also database agnostic.

Extending IdentityGenerator is an OK idea, it will fix your current problem. But you'll probably have to change (or at least add to) the code every time you change databases. The best solution is to change to something like an assigned identifier and move the PK generation method away from the database.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch Paul,

In case some one finds this useful,I achieved shift of db with out having two sets of hbm and configuration files by doing following

1) Configured Dialect using dbflag
eg : -


2) Extended MysqlDialect and OracleDialect


3) Extended SequenceGenerator

Thanks to Pietro Polsinelli. and Mr. Rob Hasselbaum for neat paper in link below
Reference


Cheers
-Praful
[ May 11, 2006: Message edited by: Praful Thakare ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic