[249847]  Store resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249847

diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index 9ada759..982c5da 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -186,19 +186,30 @@
     builder.append(CDODBSchema.ATTRIBUTES_CONTAINER);
     builder.append("=");
     builder.append(CDOIDUtil.getLong(folderID));
-    builder.append(" AND ");
-    builder.append(nameField);
-    if (exactMatch)
+    if (exactMatch || name != null)
     {
-      builder.append("=\'");
-      builder.append(name);
-      builder.append("\'");
-    }
-    else
-    {
-      builder.append(" LIKE \'");
-      builder.append(name);
-      builder.append("%\'");
+      builder.append(" AND ");
+      builder.append(nameField);
+      if (exactMatch)
+      {
+        if (name == null)
+        {
+          builder.append(" IS NULL");
+        }
+        else
+        {
+          builder.append("=\'");
+          builder.append(name);
+          builder.append("\'");
+        }
+      }
+      else
+      {
+        // Here: name != null
+        builder.append(" LIKE \'");
+        builder.append(name);
+        builder.append("%\'");
+      }
     }
 
     String sql = builder.toString();