I finally found a way, but it is specific to Hibernate.
//take from current EntityManager current DB Session Session session = (Session) em.getDelegate(); //Hibernate 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")){ ....
Dewfy source share