 core/modules/rdf/rdf.module |   44 ++++++++++++++++++++++++++++++++----------
 1 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index c53ba34..2d722bf 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -190,17 +190,36 @@ function _rdf_get_default_mapping($type) {
  *   An RDF mapping structure or an empty array if no record was found.
  */
 function _rdf_mapping_load($type, $bundle) {
-  $mapping = db_select('rdf_mapping')
-    ->fields(NULL, array('mapping'))
+  $mappings = _rdf_mapping_load_multiple($type, array($bundle));
+  return $mappings ? reset($mappings) : array();
+}
+
+/**
+ * Helper function to retreive a set of RDF mappings from the database.
+ *
+ * @param $type
+ *   The entity type of the mappings.
+ * @param $bundles
+ *   The bundles the mappings refer to.
+ *
+ * @return
+ *   An array of RDF mapping structures, or FALSE if none found.
+ */
+function _rdf_mapping_load_multiple($type, array $bundles) {
+  $mappings = db_select('rdf_mapping')
+    ->fields(NULL, array('bundle', 'mapping'))
     ->condition('type', $type)
-    ->condition('bundle', $bundle)
+    ->condition('bundle', $bundles)
     ->execute()
-    ->fetchField();
+    ->fetchAllKeyed();
 
-  if (!$mapping) {
-    return array();
+  if (!$mappings) {
+    return FALSE;
   }
-  return unserialize($mapping);
+  foreach ($mappings as $bundle => $mapping) {
+    $mappings[$bundle] = unserialize($mapping);
+  }
+  return $mappings;
 }
 
 /**
@@ -368,10 +387,13 @@ function rdf_modules_uninstalled($modules) {
 function rdf_entity_info_alter(&$entity_info) {
   // Loop through each entity type and its bundles.
   foreach ($entity_info as $entity_type => $entity_type_info) {
-    if (isset($entity_type_info['bundles'])) {
-      foreach ($entity_type_info['bundles'] as $bundle => $bundle_info) {
-        if ($mapping = _rdf_mapping_load($entity_type, $bundle)) {
-          $entity_info[$entity_type]['bundles'][$bundle]['rdf_mapping'] = $mapping;
+    if (!empty($entity_type_info['bundles'])) {
+      $bundles = array_keys($entity_type_info['bundles']);
+      $mappings = _rdf_mapping_load_multiple($entity_type, $bundles);
+
+      foreach ($bundles as $bundle) {
+        if (isset($mappings[$bundle])) {
+          $entity_info[$entity_type]['bundles'][$bundle]['rdf_mapping'] = $mappings[$bundle];
         }
         else {
           // If no mapping was found in the database, assign the default RDF
