Login  Register

Re: Dev - findByLike

Posted by Hans Bakker on Apr 29, 2006; 9:53am
URL: http://ofbiz.116.s1.nabble.com/Dev-findByLike-tp167804p167806.html

That is very quick reponse and it is working too.

Thanks very much for your help.
--
Regards,
Hans Bakker
ANT Websystems Co.,Ltd (http://www.antwebsystems.com)

If you want to verify that this message really originates from
from the above person, download the public key from:
http://www.antwebsystems.com/hbakkerAntwebsystems.asc

On Saturday 29 April 2006 15:17, Andrew Sykes wrote:

> Hans,
>
> It looks to me like GenericDelegator.findByLike is calling the wrong
> constructor method on EntityExpr. There are 2 similar constructors...
>
> The one we should use is...
> EntityExpr(java.lang.String lhs, EntityComparisonOperator operator,
> java.lang.Object rhs)
>
> The one that is actually being used is...
> EntityExpr(EntityCondition lhs, EntityJoinOperator operator,
> EntityCondition rhs)
>
> The reason the wrong one is being called is that by default
> Map.Entry.getKey() returns type Object. GenericDelegator.findByLike
> should be casting this key to type String.
>
> I've attached a patch below...
>
>
> Index: /home/andrew/eclipse-
> workspace/ofbiz/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
> ===================================================================
> --- /home/andrew/eclipse-
> workspace/ofbiz/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
> (revision 7443) +++ /home/andrew/eclipse-
> workspace/ofbiz/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
> (working copy) @@ -1666,7 +1666,7 @@
>              Iterator fieldEntries = fields.entrySet().iterator();
>              while (fieldEntries.hasNext()) {
>                  Map.Entry fieldEntry = (Map.Entry) fieldEntries.next();
> -                likeExpressions.add(new EntityExpr(fieldEntry.getKey(),
> EntityOperator.LIKE, fieldEntry.getValue()));
> +                likeExpressions.add(new EntityExpr
> ((String)fieldEntry.getKey(), EntityOperator.LIKE, fieldEntry.getValue
> ()));
>              }
>          }
>          EntityConditionList ecl = new EntityConditionList
> (likeExpressions, EntityOperator.AND);

 
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev

attachment0 (196 bytes) Download Attachment