You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Vinaya Tirikkovalluru <vi...@converge.com> on 2007/12/12 21:47:35 UTC

How do I customize the criteria

Hi,

 

I have a case where I need to do the following

 

Select * from abc.XYZ where col1 || "" Like (some value)

 

How do I do that?

I tried extending the Example class and Criteria. Had some problems,
though.

 

Was hoping somebody might have done it earlier.

 

Thanks

Vinaya



This electronic message is intended only for the use of the individual(s) or entity(ies) named above and may contain information which is privileged and/or confidential.  If you are not the intended recipient, be aware that any disclosure, copying, distribution, dissemination or use of the contents of this message is prohibited.  If you received this message in error, please notify the sender immediately.

Re: How do I customize the criteria

Posted by Jeff Butler <je...@gmail.com>.
Here's one way to do it.  First make this class...

public class MyCriteria extends XYZExample.Criteria {
  public MyCriteria addCustomCriteria(String value) {
    addCriterion("col1 || \"\" like", value, "col1");
    return this;
  }
}

Then use it like this...

XYZExample example = new XYZExample();
MyCriteria myCriteria = new MyCriteria();
example.or(myCriteria);
myCriteria.addCustomCriteria("some value");
List answer = dao.selectByExample(example);


Jeff Butler




On Dec 12, 2007 2:47 PM, Vinaya Tirikkovalluru <
vinaya.tirikkovalluru@converge.com> wrote:

>  Hi,
>
>
>
> I have a case where I need to do the following
>
>
>
> Select * from abc.XYZ where col1 || "" Like (some value)
>
>
>
> How do I do that?
>
> I tried extending the Example class and Criteria. Had some problems,
> though.
>
>
>
> Was hoping somebody might have done it earlier.
>
>
>
> Thanks
>
> Vinaya
>
> ------------------------------
> This electronic message is intended only for the use of the individual(s)
> or entity(ies) named above and may contain information which is privileged
> and/or confidential. If you are not the intended recipient, be aware that
> any disclosure, copying, distribution, dissemination or use of the contents
> of this message is prohibited. If you received this message in error, please
> notify the sender immediately.
>
>