diff --git a/modules/dbsupport/src/main/java/org/jpos/ee/DB.java b/modules/dbsupport/src/main/java/org/jpos/ee/DB.java index 16319d574a..a38249ad4e 100644 --- a/modules/dbsupport/src/main/java/org/jpos/ee/DB.java +++ b/modules/dbsupport/src/main/java/org/jpos/ee/DB.java @@ -27,8 +27,10 @@ import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; +import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.EntityKey; +import org.hibernate.internal.SessionFactoryImpl; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.resource.transaction.spi.TransactionStatus; @@ -65,6 +67,7 @@ public class DB implements Closeable { Session session; Log log; String configModifier; + private Dialect dialect; private static Map sfSems = Collections.synchronizedMap(new HashMap<>()); private static Map mdSems = Collections.synchronizedMap(new HashMap<>()); @@ -152,6 +155,10 @@ public SessionFactory getSessionFactory() { return sf; } + public Dialect getDialect() { + return dialect; + } + public static synchronized void invalidateSessionFactories() { sessionFactories.clear(); } @@ -160,7 +167,11 @@ private SessionFactory newSessionFactory() throws IOException, ConfigurationExce Metadata md = getMetadata(); try { newSessionSem.acquireUninterruptibly(); - return md.buildSessionFactory(); + SessionFactory sf = md.buildSessionFactory(); + if (sf instanceof SessionFactoryImpl) { + dialect = ((SessionFactoryImpl) sf).getJdbcServices().getDialect(); + } + return sf; } finally { newSessionSem.release(); }