]> git.basschouten.com Git - openhab-addons.git/commitdiff
Do not create table on 'query', only on 'store' (#11961)
authorChristoph Weitkamp <github@christophweitkamp.de>
Tue, 4 Jan 2022 20:26:52 +0000 (21:26 +0100)
committerGitHub <noreply@github.com>
Tue, 4 Jan 2022 20:26:52 +0000 (21:26 +0100)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.persistence.jdbc/src/main/java/org/openhab/persistence/jdbc/internal/JdbcPersistenceService.java

index 44e584303a7b8ccee40b260b2e0f2e90ba362205..bf8103d22bba32b67e29ea3a14dd8a22f5516c2a 100644 (file)
@@ -193,19 +193,16 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
 
         String table = sqlTables.get(itemName);
         if (table == null) {
-            logger.warn(
-                    "JDBC::query: unable to find table for query, no data in database for item '{}'. Current number of tables in the database: {}",
-                    itemName, sqlTables.size());
-            // if enabled, table will be created immediately
-            logger.warn("JDBC::query: try to generate the table for item '{}'", itemName);
-            table = getTable(item);
+            logger.debug("JDBC::query: unable to find table for item with name: '{}', no data in database.", itemName);
+            return List.of();
         }
 
         long timerStart = System.currentTimeMillis();
         List<HistoricItem> items = getHistItemFilterQuery(filter, conf.getNumberDecimalcount(), table, item);
-
-        logger.debug("JDBC::query: query for {} returned {} rows in {} ms", itemName, items.size(),
-                System.currentTimeMillis() - timerStart);
+        if (logger.isDebugEnabled()) {
+            logger.debug("JDBC: Query for item '{}' returned {} rows in {} ms", itemName, items.size(),
+                    System.currentTimeMillis() - timerStart);
+        }
 
         // Success
         errCnt = 0;