Forums de discussion

How to use WHERE attribute of FINDER tag in service.xml?

thumbnail
Kravchenko Dmitry, modifié il y a 12 années.

How to use WHERE attribute of FINDER tag in service.xml?

Regular Member Publications: 139 Date d'inscription: 04/10/10 Publications récentes
How to use WHERE attribute of FINDER tag in service.xml?

For example, is it possible to create finder, which receives single parameter P : String and looks for all rows where columns A and B satisfy A=P OR B=P?

In this example I need a finder column to have a name, which differs from any column name in a table. Is it possible?

Is it possible to use wilcard matching in finders, for example, how to find all rows which N field starts from "guest"?

Thanks
thumbnail
Ravi Kumar Gupta, modifié il y a 12 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Liferay Legend Publications: 1302 Date d'inscription: 24/06/09 Publications récentes
I guess its already there.. Like see this

<finder name="G_F_N" return-type="DLFileEntry" unique="true">
			<finder-column name="groupId" />
			<finder-column name="folderId" />
			<finder-column name="name" />
		</finder>

This is supposed to be a finder method with 3 arguments long, long, string.. and below is something that you are referring to(as it seems to me)

<finder name="A_B" return-type="collection">
			<finder-column name="A" />
			<finder-column name="B" />
		</finder>

provided both A and B are type string.. In the implementation according to what you want.. P will be passed as both A and B.. or say whenever you are going to call this finder method call like this..
xxx.findByA_B(P,P);


I am still learning services but I hope this is the way it works.. if not, correct me please.. emoticon
-Ravi
thumbnail
Kravchenko Dmitry, modifié il y a 12 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Regular Member Publications: 139 Date d'inscription: 04/10/10 Publications récentes
But where are you using WHERE attribute? I was interesting namely in it.
thumbnail
Amos Fong, modifié il y a 12 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Hi,

Do you mean the where attribute in <finder> as defined in the dtd?
<!--ATTLIST finder
	name CDATA #REQUIRED
	return-type CDATA #REQUIRED
	unique CDATA #IMPLIED
	where CDATA #IMPLIED
	db-index CDATA #IMPLIED
-->


Here is an example from the source code:
		<finder name="L_L_P" return-type="Collection" where="status != 5">
			<finder-column name="layoutSetBranchId" />
			<finder-column name="layoutBranchId" />
			<finder-column name="plid" />
		</finder>


As for wildcards in it, I'm not sure, try a like with %'s emoticon
thumbnail
Kravchenko Dmitry, modifié il y a 12 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Regular Member Publications: 139 Date d'inscription: 04/10/10 Publications récentes
So, according to your example, I can't use WHERE to control filtering by finder parameters? It is just an additional filtering which can't refer finder columns?

For example,


        <finder name="People" return-type="Collection" where="age <= askedage">
            <finder-column name="askedage" />
        </finder>


with no 'askedage' column in the table.
thumbnail
Nagendra Kumar Busam, modifié il y a 12 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Liferay Master Publications: 678 Date d'inscription: 07/07/09 Publications récentes
I am not sure about WHERE clause, if you want to do wild card you can do it as below

Suppose if you want search for firstNames starting with Brain pass "Brain%" OR if you want firstNames ending with Brain pass "%Brain"

        <finder name="ByFirstName" return-type="Collection">
            <finder-column name="firstName" [b]comparator="LIKE" [ b] />
        </finder>


HTH
thumbnail
kartik shiroya, modifié il y a 8 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Junior Member Publications: 47 Date d'inscription: 29/12/14 Publications récentes
Nagendra Kumar Busam:
I am not sure about WHERE clause, if you want to do wild card you can do it as below

Suppose if you want search for firstNames starting with Brain pass "Brain%" OR if you want firstNames ending with Brain pass "%Brain"

        <finder name="ByFirstName" return-type="Collection">
            <finder-column name="firstName" [b]comparator="LIKE" [ b] />
        </finder>


HTH


Hello Nagendra

If i m putting comparator="LIKE" parameter in finder column then it will search like
Select * from user_ where firstName like "test";

But i am looking for LIKE operator as like below
Select * from user_ where firstName like "%test%";

so how should i have to implement it.

Note: i am not getting for 'b' with square bracket in your comment, please elaborate it.

Regards
Kartik
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: How to use WHERE attribute of FINDER tag in service.xml?

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
kartik shiroya:
But i am looking for LIKE operator as like below
Select * from user_ where firstName like "%test%";


Just surround the value with what you are passing to the finder with the percent signs.

Note: i am not getting for 'b' with square bracket in your comment, please elaborate it.


Formatting tags such as bold are not enforced within code blocks.