Issue
I'm responsible on porting existing project from Oracle to MSSQL, but keeping both functional. Legacy project uses Hibernate 3.x, but contains some number of sophisticated native queries. So I would like to know which dialect used.
Solution
At last I've found the way - but it is specific for Hibernate.
//take from current EntityManager current DB Session
Session session = (Session) em.getDelegate();
//Hibernate's SessionFactoryImpl has property 'getDialect', to
//access this I'm using property accessor:
Object dialect =
org.apache.commons.beanutils.PropertyUtils.getProperty(
session.getSessionFactory(), "dialect");
//now this object can be casted to readable string:
if( dialect.toString().contains("Oracle")){
....
Answered By - Dewfy
Answer Checked By - Candace Johnson (JavaFixing Volunteer)