persistence@glassfish.java.net

RE: case insensitive

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Tue, 15 Jan 2008 22:53:06 +0000

Hello Micheal,
 
My query is as below:
 
 @NamedQuery(name = "GetItemsbydescodename",query = "SELECT i FROM Iteamdetailsent i WHERE UPPER(i.description) LIKE :param
OR UPPER(i.itmid) LIKE :param OR UPPER(i.itmname)LIKE :param"),
 
then in the setparameter method:
 
public List<Iteamdetailsent> Despcodename(String param){
 
.......
 
iteamdetailsent=(List<Iteamdetailsent>) em.createNamedQuery("GetItemsbydescodename").setParameter("param", param.toUpperCase()).getResultList();
 
.....}
 
and it works.
 
Thanks
 
 
 
 



Date: Mon, 14 Jan 2008 21:26:41 +0100From: mbo.tech_at_spree.deTo: persistence_at_glassfish.dev.java.netSubject: Re: case insensitive
Hi,what Gordon proposed works when using native SQL queries in JPA. Unfortunately, the Java Persistence query language only supports string literals and input parameters as pattern value following the keyword LIKE, so using the UPPER function is not supported here. But you can use the following WHERE clause: WHERE UPPER(c.name) LIKE :nameand then pass the upper case value as actual parameter value: query.setParameter("name", string.toUpperCase());Regards Michael

You could convert your query to : WHERE UPPER(c.name) LIKE UPPER(?1)
 
--Gordon

-----Original Message-----From: TianMing Pan [mailto:Tpan_at_agilitylogistics.com]Sent: Monday, January 14, 2008 6:16 AMTo: persistence_at_glassfish.dev.java.netSubject: case insensitive
Hi, When I use the JPA, I am confuse about its query for how to makeit case insensitive.For exampe, if I search in the db as "c.name like ?1" and setParameter 1as "china", thenthe result will not include the "China". So could you tell me how tomake the query caseinsensitive? Thanks a lot.RdsAll Business is handled subject to our General Trading Conditions. A copy can be made available upon request.--
Tech_at_Spree Engineering GmbH Tel.: +49/(0)30/235 520-33
Buelowstr. 66 Fax.: +49/(0)30/217 520-12
10783 Berlin mailto:mbo.tech_at_spree.de
 
Geschaeftsfuehrung: Martin Weber
Sitz Berlin, Amtsgericht Charlottenburg, HRB 564 52

_________________________________________________________________
Telly addicts unite!
http://www.searchgamesbox.com/tvtown.shtml