public InsertTempDeviationsQuery(final DataSource ds) { queryTruncateTempTable = new SqlUpdate(ds, "TRUNCATE so_deviation_temp", NO_TYPES); queryLoadDataInTempTable = new SqlUpdate(ds, "LOAD DATA LOCAL INFILE ? INTO TABLE so_deviation_temp(tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator)", new int[]{Types.VARCHAR}); queryMoveDataFromTempToCache = new SqlUpdate(ds, "INSERT INTO so_deviation_cache(tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator, written)\n" + " SELECT tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator, b'0'\n" + " FROM so_deviation_temp\n" + "ON DUPLICATE KEY UPDATE\n" + " so_deviation_cache.numerator = so_deviation_cache.numerator + VALUES(so_deviation_cache.numerator),\n" + " so_deviation_cache.denominator = so_deviation_cache.denominator + VALUES" + "(so_deviation_cache.denominator)", NO_TYPES); }
public FlushCacheQuery(final DataSource ds) { moveCacheToTableQuery = new SqlUpdate(ds, "INSERT INTO so_deviation(tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator, deviation)\n" + " SELECT tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator, (numerator/denominator)\n" + " FROM so_deviation_cache\n" + " WHERE written=b'0'\n" + "ON DUPLICATE KEY UPDATE\n" + " so_deviation.numerator = so_deviation.numerator + VALUES(so_deviation.numerator),\n" + " so_deviation.denominator = so_deviation.denominator + VALUES(so_deviation.denominator),\n" + " so_deviation.deviation = (so_deviation.numerator+VALUES(so_deviation.numerator))/(so_deviation.denominator + VALUES(so_deviation.denominator))", NO_TYPES); moveCacheToTableQuery.compile(); updateCacheWrittenQuery = new SqlUpdate(ds, "UPDATE so_deviation_cache SET numerator = 0, denominator = 0, written = b'1' WHERE written = b'0'", NO_TYPES); updateCacheWrittenQuery.compile(); reduceCacheQuery = new SqlUpdate(ds, "DELETE FROM so_deviation_cache WHERE written=b'1' LIMIT ?", new int[]{Types.INTEGER}); reduceCacheQuery.compile(); disableKeysQuery = new SqlUpdate(ds, "ALTER TABLE so_deviation DISABLE KEYS", NO_TYPES); disableKeysQuery.compile(); enableKeysQuery = new SqlUpdate(ds, "ALTER TABLE so_deviation ENABLE KEYS", NO_TYPES); enableKeysQuery.compile(); }
this.compiledDeleteMessageForLangQuery = this.compileQuery(this.deleteMessageForLangQuery); this.insertMessageSqlUpdate = new SqlUpdate(this.getDataSource(), this.compiledInsertMessageQuery, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, }); this.updateMessageSqlUpdate = new SqlUpdate(this.getDataSource(), this.compiledUpdateMessageQuery, new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, }); this.deleteMessageSqlUpdate = new SqlUpdate(this.getDataSource(), this.compiledDeleteMessageQuery, new int[] { Types.VARCHAR }); this.deleteMessageForLangSqlUpdate = new SqlUpdate(this.getDataSource(), this.compiledDeleteMessageForLangQuery, new int[] { Types.VARCHAR, Types.VARCHAR });
setDataSource(dataSource); createConfiguration = new SqlUpdate(dataSource, "INSERT INTO plugin_configuration(tenantId, assocTypeId, pluginId, pluginVersion, name, " + "configuration, active) VALUES(?, ?, ?, ?, ?, ?, ?)", createConfiguration.compile(); updateConfigurationActive = new SqlUpdate(dataSource, "UPDATE plugin_configuration SET name = ?, configuration = ?, active = b'1' " + "WHERE tenantId = ? AND assocTypeId = ? AND pluginId = ? AND pluginVersion = ? AND name = ?", updateConfigurationInactive = new SqlUpdate(dataSource, "UPDATE plugin_configuration SET name = ?, configuration = ? " + "WHERE tenantId = ? AND assocTypeId = ? AND pluginId = ? AND pluginVersion = ? AND name = ?", updateAllInactive = new SqlUpdate(dataSource, "UPDATE plugin_configuration SET active = b'0' WHERE tenantId = ? AND assocTypeId = ?", new int[]{Types.INTEGER, Types.INTEGER}); updateSetInactiveByPluginId = new SqlUpdate(dataSource, "UPDATE plugin_configuration SET active = b'0' WHERE pluginId = ? AND pluginVersion = ?", new int[]{Types.VARCHAR, Types.VARCHAR}); deleteConfiguration = new SqlUpdate(dataSource, "DELETE FROM plugin_configuration WHERE tenantId = ? AND assocTypeId = ? AND pluginId = ? AND " + "pluginVersion = ? AND name = ? AND active = b'0'",
startEntry = new SqlUpdate(dataSource, "INSERT INTO plugin_log(tenantId, pluginId, pluginVersion, startDate, assocTypeId, " + "configuration) VALUES (?, ?, ?, ?, ?, ?)", endEntry = new SqlUpdate(dataSource, "INSERT INTO plugin_log(tenantId, pluginId, pluginVersion, startDate, assocTypeId, configuration, " + "endDate, statistics) VALUES (?, ?, ?, ?, ?, ?, ?, ?) " + endAllEntries = new SqlUpdate(dataSource, "UPDATE plugin_log SET endDate = ?, statistics = ? WHERE endDate IS NULL", new int[]{Types.TIMESTAMP, Types.BLOB}); deleteLogEntries = new SqlUpdate(dataSource, "TRUNCATE plugin_log"); deleteLogEntries.compile(); deleteLogEntryStatement = new SqlUpdate(dataSource, "DELETE FROM plugin_log WHERE tenantId = ? AND pluginId = ? AND pluginVersion = ? AND startDate = ? AND assocTypeId = ?"); deleteLogEntryStatement.declareParameter(new SqlParameter("tenantId", Types.INTEGER));
QUERY_GET_ITEMIDS.compile(); QUERY_INSERT_CACHED_DEVIATION = new SqlUpdate(getDataSource(), "INSERT INTO so_deviation_cache(tenantId, item1Id, item2Id, item1TypeId, item2TypeId, numerator, denominator, written)\n" + " VALUES (?, ?, ?, ?, ?, ?, ?, b'0')\n" +