Skip to content

Commit

Permalink
add getDialect() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Sep 9, 2019
1 parent 4f8d3af commit ce5a893
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/dbsupport/src/main/java/org/jpos/ee/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,6 +67,7 @@ public class DB implements Closeable {
Session session;
Log log;
String configModifier;
private Dialect dialect;

private static Map<String,Semaphore> sfSems = Collections.synchronizedMap(new HashMap<>());
private static Map<String,Semaphore> mdSems = Collections.synchronizedMap(new HashMap<>());
Expand Down Expand Up @@ -152,6 +155,10 @@ public SessionFactory getSessionFactory() {
return sf;
}

public Dialect getDialect() {
return dialect;
}

public static synchronized void invalidateSessionFactories() {
sessionFactories.clear();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit ce5a893

Please # to comment.