Index: includes/entity.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/entity.inc,v
retrieving revision 1.1
diff -u -p -r1.1 entity.inc
--- includes/entity.inc	25 Aug 2009 21:53:47 -0000	1.1
+++ includes/entity.inc	3 Sep 2009 04:50:55 -0000
@@ -189,14 +189,6 @@ class DrupalDefaultEntityController impl
       // The id field is provided by entity, so remove it.
       unset($entity_revision_fields[$this->idKey]);
 
-      // Change timestamp to revision_timestamp, and revision uid to
-      // revision_uid before adding them to the query.
-      // TODO: This is node specific and has to be moved into NodeController.
-      unset($entity_revision_fields['timestamp']);
-      $this->query->addField('revision', 'timestamp', 'revision_timestamp');
-      unset($entity_revision_fields['uid']);
-      $this->query->addField('revision', 'uid', 'revision_uid');
-
       // Remove all fields from the base table that are also fields by the same
       // name in the revision table.
       $entity_field_keys = array_flip($entity_fields);
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1118
diff -u -p -r1.1118 node.module
--- modules/node/node.module	1 Sep 2009 16:50:11 -0000	1.1118
+++ modules/node/node.module	3 Sep 2009 04:50:57 -0000
@@ -3119,4 +3119,55 @@ class NodeController extends DrupalDefau
     $this->hookLoadArguments[] = array_keys($typed_nodes);
     parent::attachLoad($nodes);
   }
+
+  protected function buildQuery() {
+    $this->query = db_select($this->entityInfo['base table'], 'base');
+
+    $this->query->addTag($this->entityType . '_load_multiple');
+
+    if ($this->revisionId) {
+      $this->query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $this->revisionId));
+    }
+    elseif ($this->revisionKey) {
+      $this->query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}");
+    }
+
+    // Add fields from the {entity} table.
+    $entity_fields = drupal_schema_fields_sql($this->entityInfo['base table']);
+
+    if ($this->revisionKey) {
+      // Add all fields from the {entity_revision} table.
+      $entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->revisionTable));
+      // The id field is provided by entity, so remove it.
+      unset($entity_revision_fields[$this->idKey]);
+
+      // Change timestamp to revision_timestamp, and revision uid to
+      // revision_uid before adding them to the query.
+      unset($entity_revision_fields['timestamp']);
+      $this->query->addField('revision', 'timestamp', 'revision_timestamp');
+      unset($entity_revision_fields['uid']);
+      $this->query->addField('revision', 'uid', 'revision_uid');
+
+      // Remove all fields from the base table that are also fields by the same
+      // name in the revision table.
+      $entity_field_keys = array_flip($entity_fields);
+      foreach ($entity_revision_fields as $key => $name) {
+        if (isset($entity_field_keys[$name])) {
+          unset($entity_fields[$entity_field_keys[$name]]);
+        }
+      }
+      $this->query->fields('revision', $entity_revision_fields);
+    }
+
+    $this->query->fields('base', $entity_fields);
+
+    if ($this->ids) {
+      $this->query->condition("base.{$this->idKey}", $this->ids, 'IN');
+    }
+    if ($this->conditions) {
+      foreach ($this->conditions as $field => $value) {
+        $this->query->condition('base.' . $field, $value);
+      }
+    }
+  }
 }
