|
Hi there - I did a search but received a lot of results that didn't look like what I was looking for so hopefully someone can help me out. Our company has several products. One of these products uses hibernate and only supports postgresql(A). Another product supports both oracle and postgresql but performs better with oracle.(B)
For product (B) we were setting the hibernate dialect as a jvm property in the glassfish admin page so that we could ship one EAR that worked with either database. For some reason our dba wants hibernate to use the oracle 9i dialect instead of trying to use newer ones if a newer oracle is detected. Anyhow this seemed to work well.
For product (A) we were setting the dialect in the persistance.xml for the ear - and it was checked in and built with postgresql since that is the only db currently supported.
I got put in a situation where we wanted to run both apps in one container with (A) pointing to postgresql and (B) pointing to oracle - it took me a while to figure out that Oracle dialect was being used even in application (A) and causing failures.
Since we're running JEE 5 I've been banging my head against the wall trying to figure out how to programatically set the dialect at app startup - basically if db = oracle(anyversion) use dialect oracle9i, else use postgres. I haven't arrived at a good method although JEE 6 with singleton @startup looks promising when it shows up. However in the meantime, is there any way I can configure hibernate to prefer a specific dialect for a given database type? If so I could turn off the explicit setting because Hibernate would see oracle or postgress and choose appropriately.....again the main sticking point is we wanted consistant behavior so I need it to default to 9i if it sees oracle, even if oracle 11 is actually there.
|