static public function buildSearchPattern(common_persistence_SqlPersistence $persistence, $pattern, $like = true)
    {
        $returnValue = '';
        
        // Take care of RDFS Literals!
        if ($pattern instanceof core_kernel_classes_Literal) {
            $pattern = $pattern->__toString();
        }
        
        switch (gettype($pattern)) {
            case 'object' :
                if ($pattern instanceof core_kernel_classes_Resource) {
                    $returnValue = '= ' . $persistence->quote($pattern->getUri());
                } else {
                    common_Logger::w('non ressource as search parameter: '. get_class($pattern), 'GENERIS');
                }
                break;
            
            default:
                $patternToken = $pattern;
                $wildcard = mb_strpos($patternToken, '*', 0, 'UTF-8') !== false;
                $object = trim(str_replace('*', '%', $patternToken));
                
                if ($like) {
                    if (!$wildcard && !preg_match("/^%/", $object)) {
                        $object = "%" . $object;
                    }
                    if (!$wildcard && !preg_match("/%$/", $object)) {
                        $object = $object . "%";
                    }
                    if (!$wildcard && $object === '%') {
                        $object = '%%';
                    }
                    $returnValue .= 'LIKE LOWER(' . $persistence->quote($object) . ')';
                } else {
                    $returnValue .= '= '. $persistence->quote($patternToken);
                }
                break;
        }
        
        return $returnValue;
    }