                 // to-one
                 if !relationshipDescription!.toMany {
                     
-                    let resourceID = jsonPredicateValue as? UInt
+                    let resourceDictionary = jsonPredicateValue as? [String: UInt]
                     
                     // verify
-                    if resourceID == nil {
+                    if resourceDictionary == nil || resourceDictionary?.count != 1  {
                         
                         let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                         
                         return (response, userInfo)
                     }
                     
-                    let (fetchedResource, error) = self.fetchEntity(relationshipDescription!.destinationEntity!, withResourceID: resourceID!, usingContext: context, shouldPrefetch: false)
+                    let resourceID = resourceDictionary!.values.first!
+                    
+                    let resourceEntityName = resourceDictionary!.keys.first!
+                    
+                    let resourceEntity = self.managedObjectModel.entitiesByName[resourceEntityName] as? NSEntityDescription
+                    
+                    // verify
+                    if resourceEntity == nil || !(resourceEntity?.isKindOfEntity(relationshipDescription!.destinationEntity!) ?? true) {
+                        
+                        let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
+                        
+                        return (response, userInfo)
+                    }
+                    
+                    let (fetchedResource, error) = self.fetchEntity(resourceEntity!, withResourceID: resourceID, usingContext: context, shouldPrefetch: false)
                     
                     // error fetching
                     if error != nil {

        
        if (predicateKey != nil) && (predicateOperator != nil) && (jsonPredicateValue != nil) {
            
            // validate operator
            
            if predicateOperatorNumber == NSPredicateOperatorType.CustomSelectorPredicateOperatorType.rawValue {
                
                let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                

                // to-many relationships
                else {
                    
                    let resourceDictionaries = jsonPredicateValue as? [[String: UInt]]
                    
                    // verify
                    if resourceDictionaries == nil {
                        
                        let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                        
                        return (response, userInfo)
                    }
                    
                    var fetchedManagedObjects = [NSManagedObject]()
                    
                    for resourceDictionary in resourceDictionaries! {
                        
                        // verify
                        if resourceDictionary.count != 1  {
                            
                            let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                            
                            return (response, userInfo)
                        }
                        
                        let resourceID = resourceDictionary.values.first!
                        
                        let resourceEntityName = resourceDictionary.keys.first!
                        
                        let resourceEntity = self.managedObjectModel.entitiesByName[resourceEntityName] as? NSEntityDescription
                        
                        // verify
                        if resourceEntity == nil || !(resourceEntity?.isKindOfEntity(relationshipDescription!.destinationEntity!) ?? true)  {
                            
                            let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                            
                            return (response, userInfo)
                        }
                        
                        let (fetchedResource, error) = self.fetchEntity(resourceEntity!, withResourceID: resourceID, usingContext: context, shouldPrefetch: false)
                        
                        // error fetching
                        if error != nil {
                            
                            // tell delegate
                            self.delegate?.server(self, didEncounterInternalError: error!, forRequest: request, userInfo: userInfo)
                            
                            let response = ServerResponse(statusCode: ServerStatusCode.InternalServerError, JSONResponse: nil)
                            
                            return (response, userInfo)
                        }
                        
                        // not found
                        if fetchedResource == nil {
                            
                            let response = ServerResponse(statusCode: ServerStatusCode.BadRequest, JSONResponse: nil)
                            
                            return (response, userInfo)
                        }
                        
                        fetchedManagedObjects.append(fetchedResource!)
                    }
                    
                    // set value
                    value = fetchedManagedObjects
                }
            }
            
