details:   https://code.openbravo.com/erp/devel/pi/rev/de556f74afd6
changeset: 33186:de556f74afd6
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Mon Jan 15 17:40:00 2018 +0100
summary:   Fixes issue 37641: Allows to configure Hibernate's hql query plan 
cache size

Now the max size of Hibernate's HQL query plan cache can be configured in 
Openbravo.properties by defining the
hibernate.query.plan_cache_max_strong_references and 
hibernate.query.plan_cache_max_soft_references properties.

diffstat:

 src/org/openbravo/base/session/SessionFactoryController.java |  36 ++++++++++--
 1 files changed, 30 insertions(+), 6 deletions(-)

diffs (78 lines):

diff -r 385dc5c17396 -r de556f74afd6 
src/org/openbravo/base/session/SessionFactoryController.java
--- a/src/org/openbravo/base/session/SessionFactoryController.java      Fri Jan 
12 02:12:24 2018 +0530
+++ b/src/org/openbravo/base/session/SessionFactoryController.java      Mon Jan 
15 17:40:00 2018 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2017 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2018 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -19,6 +19,7 @@
 
 package org.openbravo.base.session;
 
+import java.util.Enumeration;
 import java.util.Properties;
 
 import org.apache.log4j.Logger;
@@ -157,6 +158,16 @@
       
configuration.getProperties().setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, 
"50");
       
configuration.getProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, 
"10");
       
configuration.getProperties().setProperty(Environment.STATEMENT_FETCH_SIZE, 
"50");
+      if 
(properties.containsKey(Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES)) {
+        configuration.getProperties().setProperty(
+            Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES,
+            
properties.getProperty(Environment.QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES));
+      }
+      if 
(properties.containsKey(Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES)) {
+        
configuration.getProperties().setProperty(Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES,
+            
properties.getProperty(Environment.QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES));
+      }
+
       
configuration.getProperties().setProperty("javax.persistence.validation.mode", 
"NONE");
       // TODO: consider setting isolation level explicitly
       // configuration.getProperties().setProperty(Environment.ISOLATION,
@@ -188,22 +199,35 @@
   protected abstract void mapModel(Configuration theConfiguration);
 
   protected Properties getOpenbravoProperties() {
-    final Properties props = new Properties();
     final Properties obProps = 
OBPropertiesProvider.getInstance().getOpenbravoProperties();
     if (obProps == null) {
       return new Properties();
     }
 
+    Properties props = new Properties();
     if (obProps.getProperty("bbdd.rdbms") != null) {
       if (obProps.getProperty("bbdd.rdbms").equals("POSTGRE")) {
-        return getPostgresHbProps(obProps);
+        props = getPostgresHbProps(obProps);
       } else if (obProps.getProperty("bbdd.rdbms").equals("DB2")) {
-        return getDB2HbProps(obProps);
+        props = getDB2HbProps(obProps);
+      } else {
+        props = getOracleHbProps(obProps);
       }
+    }
+    addCommonHibernateProperties(props, obProps);
 
-      return getOracleHbProps(obProps);
+    return props;
+  }
+
+  @SuppressWarnings("unchecked")
+  private void addCommonHibernateProperties(Properties properties, Properties 
allProperties) {
+    Enumeration<String> allPropertyNames = (Enumeration<String>) 
allProperties.propertyNames();
+    while (allPropertyNames.hasMoreElements()) {
+      String propertyName = allPropertyNames.nextElement();
+      if (propertyName.startsWith("hibernate.")) {
+        properties.put(propertyName, allProperties.getProperty(propertyName));
+      }
     }
-    return props;
   }
 
   private Properties getPostgresHbProps(Properties obProps) {

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to