Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MySQL to Oracle

 
Ranch Hand
Posts: 645
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE 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: 645
  • 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 ]
    Bookmark Topic Watch Topic
  • New Topic