Foros de discusión

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

thumbnail
Kravchenko Dmitry, modificado hace 12 años.

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

Regular Member Mensajes: 139 Fecha de incorporación: 4/10/10 Mensajes recientes
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 hace 12 años.

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

Liferay Legend Mensajes: 1302 Fecha de incorporación: 24/06/09 Mensajes recientes
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 hace 12 años.

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

Regular Member Mensajes: 139 Fecha de incorporación: 4/10/10 Mensajes recientes
But where are you using WHERE attribute? I was interesting namely in it.
thumbnail
Amos Fong, modificado hace 12 años.

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

Liferay Legend Mensajes: 2047 Fecha de incorporación: 7/10/08 Mensajes recientes
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 hace 12 años.

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

Regular Member Mensajes: 139 Fecha de incorporación: 4/10/10 Mensajes recientes
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 hace 12 años.

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

Liferay Master Mensajes: 678 Fecha de incorporación: 7/07/09 Mensajes recientes
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 hace 8 años.

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

Junior Member Mensajes: 47 Fecha de incorporación: 29/12/14 Mensajes recientes
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 hace 8 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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.