Fórum

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

thumbnail
Kravchenko Dmitry, modificado 12 Anos atrás.

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

Regular Member Postagens: 139 Data de Entrada: 04/10/10 Postagens Recentes
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, modificado 12 Anos atrás.

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

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
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, modificado 12 Anos atrás.

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

Regular Member Postagens: 139 Data de Entrada: 04/10/10 Postagens Recentes
But where are you using WHERE attribute? I was interesting namely in it.
thumbnail
Amos Fong, modificado 12 Anos atrás.

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

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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, modificado 12 Anos atrás.

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

Regular Member Postagens: 139 Data de Entrada: 04/10/10 Postagens Recentes
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, modificado 12 Anos atrás.

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

Liferay Master Postagens: 678 Data de Entrada: 07/07/09 Postagens Recentes
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, modificado 8 Anos atrás.

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

Junior Member Postagens: 47 Data de Entrada: 29/12/14 Postagens Recentes
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, modificado 8 Anos atrás.

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

Liferay Legend Postagens: 14914 Data de Entrada: 02/09/06 Postagens Recentes
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.