Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Florencia Gadea
case insensitive Dynamic Query
November 16, 2012 6:47 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 159

Join Date: March 27, 2012

Recent Posts

Hi Everyone,

Here is my dynamic query:

1
2DynamicQuery query = DynamicQueryFactoryUtil.forClass(MessageSource.class);
3query.add(PropertyFactoryUtil.forName("resourceValue").like("%" + resourceValue + "%"));
4query.add(PropertyFactoryUtil.forName("resourceBundle").eq(resourceBundle));


I would like the search to be case insensitive. Is it possible with DynamicQuery? Do I have to add something in the service builder?

TIA,

Flor.
Alireza Zare
RE: case insensitive Dynamic Query
November 16, 2012 7:15 AM
Answer

Alireza Zare

Rank: Regular Member

Posts: 110

Join Date: September 3, 2010

Recent Posts

Hi,

Look at this link:
http://www.liferay.com/community/forums/-/message_boards/message/3936565
Hitoshi Ozawa
RE: case insensitive Dynamic Query
November 16, 2012 7:22 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Have you tried using "ilike" instead of "like"
Florencia Gadea
RE: case insensitive Dynamic Query
November 16, 2012 7:40 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 159

Join Date: March 27, 2012

Recent Posts

Alireza Zare:
Hi,

Look at this link:
http://www.liferay.com/community/forums/-/message_boards/message/3936565


Hi!

Thank you, it worked! I was supposed to use RestrictionsFactoryUtil instead of PropertyFactoryUtil.

This is how my query ended up:

1DynamicQuery query = DynamicQueryFactoryUtil.forClass(MessageSource.class);
2query.add(RestrictionsFactoryUtil.ilike("resourceValue", "%" + resourceValue + "%"));
3query.add(RestrictionsFactoryUtil.ilike("resourceBundle", resourceBundle));


Best regards!

Flor