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?
All desirable things in life are either illegal, banned, expensive or married to someone else !!!
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.