summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAnna Koskinen <anna@vaadin.com>2012-12-21 16:53:54 +0200
committerAnna Koskinen <anna@vaadin.com>2012-12-21 16:53:54 +0200
commit395dad4cd7a854314e42dca2eb9dd2879ba53de8 (patch)
tree32a1e2225fcf28dbd9bb1f6bc49b77d3dcc1d407 /server
parent3f4c7a849dc219b3d458248bb812fa827ba2c898 (diff)
downloadvaadin-framework-395dad4cd7a854314e42dca2eb9dd2879ba53de8.tar.gz
vaadin-framework-395dad4cd7a854314e42dca2eb9dd2879ba53de8.zip
Merge of (#9529) to Vaadin 7.
Limit unnecessary database queries. Change-Id: Iae2ed72dd2d044f02abe775f2289126c5f5dbe1d
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index 12cb892090..065810a7b4 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -854,7 +854,21 @@ public class SQLContainer implements Container, Container.Filterable,
* Does NOT remove sorting or filtering rules!
*/
public void refresh() {
- sizeDirty = true;
+ refresh(true);
+ }
+
+ /**
+ * Refreshes the container. If <code>setSizeDirty</code> is
+ * <code>false</code>, assumes that the current size is up to date. This is
+ * used in {@link #updateCount()} to refresh the contents when we know the
+ * size was just updated.
+ *
+ * @param setSizeDirty
+ */
+ private void refresh(boolean setSizeDirty) {
+ if (setSizeDirty) {
+ sizeDirty = true;
+ }
currentOffset = 0;
cachedItems.clear();
itemIndexes.clear();
@@ -1105,12 +1119,13 @@ public class SQLContainer implements Container, Container.Filterable,
"The query delegate doesn't support filtering", e);
}
int newSize = delegate.getCount();
+ sizeUpdated = new Date();
+ sizeDirty = false;
if (newSize != size) {
size = newSize;
- refresh();
+ // Size is up to date so don't set it back to dirty in refresh()
+ refresh(false);
}
- sizeUpdated = new Date();
- sizeDirty = false;
getLogger().log(Level.FINER,
"Updated row count. New count is: " + size);
} catch (SQLException e) {