2323import java .lang .annotation .Annotation ;
2424import java .util .HashSet ;
2525import java .util .Map ;
26+ import java .util .Objects ;
2627import java .util .Optional ;
2728import java .util .Set ;
2829
2930import org .springframework .data .domain .Example ;
3031import org .springframework .data .domain .ExampleMatcher ;
3132import org .springframework .data .mapping .AssociationHandler ;
3233import org .springframework .data .mapping .PersistentPropertyAccessor ;
34+
3335import org .springframework .util .Assert ;
36+ import org .springframework .util .ClassUtils ;
3437
3538import com .arangodb .springframework .core .convert .resolver .ReferenceResolver ;
3639import com .arangodb .springframework .core .convert .resolver .ResolverFactory ;
@@ -78,10 +81,15 @@ private void traversePropertyTree(final Example<T> example, final StringBuilder
7881 final ArangoPersistentEntity <?> persistentEntity = context
7982 .getPersistentEntity (property .getActualType ());
8083 final StringBuilder predicateBuilderArray = new StringBuilder ();
81- for (Object item : (Iterable ) value ) {
84+ for (Object item : (Iterable <?> ) value ) {
8285 final StringBuilder predicateBuilderArrayItem = new StringBuilder ();
83- traversePropertyTree (example , predicateBuilderArrayItem , bindVars , "" , fullJavaPath ,
84- persistentEntity , item , "CURRENT" );
86+ if (ClassUtils .isPrimitiveOrWrapper (item .getClass ()) || item .getClass () == String .class ) {
87+ addPredicate (example , predicateBuilderArrayItem , bindVars , null , fullJavaPath , item , "CURRENT" );
88+ } else {
89+ traversePropertyTree (example , predicateBuilderArrayItem , bindVars , "" , fullJavaPath ,
90+ persistentEntity , item , "CURRENT" );
91+ }
92+
8593 if (predicateBuilderArray .length () > 0 ) {
8694 predicateBuilderArray .append (" OR " );
8795 }
@@ -154,9 +162,18 @@ private void addPredicate(final Example<T> example, final StringBuilder predicat
154162 : specifier .getStringMatcher ();
155163 final String string = (String ) value ;
156164 if (stringMatcher == ExampleMatcher .StringMatcher .REGEX ) {
157- clause = String .format ("REGEX_TEST(%s.%s, @%s, %b)" , bindEntintyName , fullPath , binding , ignoreCase );
165+ if (Objects .isNull (fullPath )) {
166+ clause = String .format ("REGEX_TEST(%s, @%s, %b)" , bindEntintyName , binding , ignoreCase );
167+ } else {
168+ clause = String .format ("REGEX_TEST(%s.%s, @%s, %b)" , bindEntintyName , fullPath , binding ,
169+ ignoreCase );
170+ }
158171 } else {
159- clause = String .format ("LIKE(%s.%s, @%s, %b)" , bindEntintyName , fullPath , binding , ignoreCase );
172+ if (Objects .isNull (fullPath )) {
173+ clause = String .format ("LIKE(%s, @%s, %b)" , bindEntintyName , binding , ignoreCase );
174+ } else {
175+ clause = String .format ("LIKE(%s.%s, @%s, %b)" , bindEntintyName , fullPath , binding , ignoreCase );
176+ }
160177 }
161178 switch (stringMatcher ) {
162179 case STARTING :
@@ -178,7 +195,12 @@ private void addPredicate(final Example<T> example, final StringBuilder predicat
178195 break ;
179196 }
180197 } else {
181- clause = String .format ("%s.%s == @%s" , bindEntintyName , fullPath , binding );
198+ if (Objects .isNull (fullPath )) {
199+ clause = String .format ("%s == @%s" , bindEntintyName , binding );
200+ } else {
201+ clause = String .format ("%s.%s == @%s" , bindEntintyName , fullPath , binding );
202+ }
203+
182204 }
183205 predicateBuilder .append (clause );
184206 if (value != null ) {
0 commit comments