You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Ramah <ra...@gft.com> on 2003/12/19 11:10:36 UTC
Using Upper and Lower functions in Criteria
BlankIs there any possibility to use UPPER and LOWER function of SQL in
Criteria?
Ex: Select eid from employee where upper(ename)='XYZ'.
How to create Criteria for the above Query?
Thanks in Advance,
Ramah
RE: Using Upper and Lower functions in Criteria
Posted by Ramah <ra...@gft.com>.
This works fine.
Thank you,
Ramah
-----Original Message-----
From: David Hainlin [mailto:dhainlin@comcast.net]
Sent: Friday, December 19, 2003 7:06 PM
To: Apache Torque Users List
Subject: Re: Using Upper and Lower functions in Criteria
Ramah,
Try something on the order or (in employee_peer)
Criteria crit = new Criteria();
...
crit.add(ENAME, (Object) ("UPPER(" + ENAME + ") = '" + name.trim() +
"'"), Criteria.CUSTOM);
...
List vals = doSelect(crit);
There may be other ways too but this technique will work for lots of
SQL situations (like date ranges, for example).
HTH
David
Ramah wrote:
> Is there any possibility to use UPPER and LOWER function of SQL in
> Criteria?
>
> *Ex: Select eid from employee where upper(ename)='XYZ'.
> How to create Criteria for the above Query?*
>
> Thanks in Advance,
> Ramah
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Using Upper and Lower functions in Criteria
Posted by David Hainlin <dh...@comcast.net>.
Ramah,
Try something on the order or (in employee_peer)
Criteria crit = new Criteria();
...
crit.add(ENAME, (Object) ("UPPER(" + ENAME + ") = '" + name.trim() +
"'"), Criteria.CUSTOM);
...
List vals = doSelect(crit);
There may be other ways too but this technique will work for lots of
SQL situations (like date ranges, for example).
HTH
David
Ramah wrote:
> Is there any possibility to use UPPER and LOWER function of SQL in
> Criteria?
>
> *Ex: Select eid from employee where upper(ename)='XYZ'.
> How to create Criteria for the above Query?*
>
> Thanks in Advance,
> Ramah
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Using Upper and Lower functions in Criteria
Posted by Scott Eade <se...@backstagetech.com.au>.
Okay, I'm not going to go back and look into why this code doesn't work
in torque-3.0 so until you upgrade to torque-3.1 you should use the
solution provided by David
Hainlin.
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
Ramah wrote:
>Pls follow Ramah :>
>
>-----Original Message-----
>From: Scott Eade [mailto:seade@backstagetech.com.au]
>Sent: Monday, December 22, 2003 12:12 PM
>To: Apache Torque Users List
>Subject: Re: Using Upper and Lower functions in Criteria
>
>
>On the surface the code looks good. I do something similar but I have
>done some patches in this area for PostgreSQL.
>
>What exact version of Torque are you using and what database?
>
>Ramah :>
>Version of Torque - torque-3.0
>Database - oracle 8.1.7
>Database driver - oracle.jdbc.driver.OracleDriver
>
>It shouldn't impact the NPE, but does eName include one or more search
>characters?
>
>Ramah :>
>No, eName won't have any search characters like %,?.
>
>Scott
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Using Upper and Lower functions in Criteria
Posted by Ramah <ra...@gft.com>.
Pls follow Ramah :>
-----Original Message-----
From: Scott Eade [mailto:seade@backstagetech.com.au]
Sent: Monday, December 22, 2003 12:12 PM
To: Apache Torque Users List
Subject: Re: Using Upper and Lower functions in Criteria
On the surface the code looks good. I do something similar but I have
done some patches in this area for PostgreSQL.
What exact version of Torque are you using and what database?
Ramah :>
Version of Torque - torque-3.0
Database - oracle 8.1.7
Database driver - oracle.jdbc.driver.OracleDriver
It shouldn't impact the NPE, but does eName include one or more search
characters?
Ramah :>
No, eName won't have any search characters like %,?.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
Ramah wrote:
>Heres the code which results in Null Pointer Exception
>
> criteria=new Criteria();
> criteria.add(EmpPeer.ENAME,(Object)eName,Criteria.LIKE);
> criteria.getCriterion(EmpPeer.ENAME).setIgnoreCase(true);
> List list=EmpPeer.doSelect(criteria);
>
>I get the exception in the last line of the code.
>
>Is anything to be modified?
>
>Thanks and Regards
>Ramah
>
>-----Original Message-----
>From: Scott Eade [mailto:seade@backstagetech.com.au]
>Sent: Saturday, December 20, 2003 6:05 PM
>To: Apache Torque Users List
>Subject: Re: Using Upper and Lower functions in Criteria
>
>
>Please post the code that builds the criteria that resulted in the NPE.
>
>Scott
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Using Upper and Lower functions in Criteria
Posted by Scott Eade <se...@backstagetech.com.au>.
On the surface the code looks good. I do something similar but I have
done some patches in this area for PostgreSQL.
What exact version of Torque are you using and what database?
It shouldn't impact the NPE, but does eName include one or more search
characters?
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
Ramah wrote:
>Heres the code which results in Null Pointer Exception
>
> criteria=new Criteria();
> criteria.add(EmpPeer.ENAME,(Object)eName,Criteria.LIKE);
> criteria.getCriterion(EmpPeer.ENAME).setIgnoreCase(true);
> List list=EmpPeer.doSelect(criteria);
>
>I get the exception in the last line of the code.
>
>Is anything to be modified?
>
>Thanks and Regards
>Ramah
>
>-----Original Message-----
>From: Scott Eade [mailto:seade@backstagetech.com.au]
>Sent: Saturday, December 20, 2003 6:05 PM
>To: Apache Torque Users List
>Subject: Re: Using Upper and Lower functions in Criteria
>
>
>Please post the code that builds the criteria that resulted in the NPE.
>
>Scott
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Using Upper and Lower functions in Criteria
Posted by Ramah <ra...@gft.com>.
Heres the code which results in Null Pointer Exception
criteria=new Criteria();
criteria.add(EmpPeer.ENAME,(Object)eName,Criteria.LIKE);
criteria.getCriterion(EmpPeer.ENAME).setIgnoreCase(true);
List list=EmpPeer.doSelect(criteria);
I get the exception in the last line of the code.
Is anything to be modified?
Thanks and Regards
Ramah
-----Original Message-----
From: Scott Eade [mailto:seade@backstagetech.com.au]
Sent: Saturday, December 20, 2003 6:05 PM
To: Apache Torque Users List
Subject: Re: Using Upper and Lower functions in Criteria
Please post the code that builds the criteria that resulted in the NPE.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
Ramah wrote:
>When I tried,
>
>criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
>
>The following exception occurs.
>
>
>java.lang.NullPointerException
> at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1066)
> at org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
> ...
>
>Thanks and Regards,
>Ramah
>
>
>
>-----Original Message-----
>From: Scott Eade [mailto:seade@backstagetech.com.au]
>Sent: Saturday, December 20, 2003 7:34 AM
>To: Apache Torque Users List
>Subject: Re: Using Upper and Lower functions in Criteria
>
>
>Ramah wrote:
>
>
>
>>Is there any possibility to use UPPER and LOWER function of SQL in
>>Criteria?
>>
>>*Ex: Select eid from employee where upper(ename)='XYZ'.
>>How to create Criteria for the above Query?*
>>
>>
>>
>
>try:
>
> criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
>
>Scott
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Using Upper and Lower functions in Criteria
Posted by Scott Eade <se...@backstagetech.com.au>.
Please post the code that builds the criteria that resulted in the NPE.
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
Ramah wrote:
>When I tried,
>
>criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
>
>The following exception occurs.
>
>
>java.lang.NullPointerException
> at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1066)
> at org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
> ...
>
>Thanks and Regards,
>Ramah
>
>
>
>-----Original Message-----
>From: Scott Eade [mailto:seade@backstagetech.com.au]
>Sent: Saturday, December 20, 2003 7:34 AM
>To: Apache Torque Users List
>Subject: Re: Using Upper and Lower functions in Criteria
>
>
>Ramah wrote:
>
>
>
>>Is there any possibility to use UPPER and LOWER function of SQL in
>>Criteria?
>>
>>*Ex: Select eid from employee where upper(ename)='XYZ'.
>>How to create Criteria for the above Query?*
>>
>>
>>
>
>try:
>
> criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
>
>Scott
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: Using Upper and Lower functions in Criteria
Posted by Ramah <ra...@gft.com>.
When I tried,
criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
The following exception occurs.
java.lang.NullPointerException
at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1066)
at org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
...
Thanks and Regards,
Ramah
-----Original Message-----
From: Scott Eade [mailto:seade@backstagetech.com.au]
Sent: Saturday, December 20, 2003 7:34 AM
To: Apache Torque Users List
Subject: Re: Using Upper and Lower functions in Criteria
Ramah wrote:
> Is there any possibility to use UPPER and LOWER function of SQL in
> Criteria?
>
> *Ex: Select eid from employee where upper(ename)='XYZ'.
> How to create Criteria for the above Query?*
>
try:
criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: Using Upper and Lower functions in Criteria
Posted by Scott Eade <se...@backstagetech.com.au>.
Ramah wrote:
> Is there any possibility to use UPPER and LOWER function of SQL in
> Criteria?
>
> *Ex: Select eid from employee where upper(ename)='XYZ'.
> How to create Criteria for the above Query?*
>
try:
criteria.getCriterion(YourPeerPeer.ENAME).setIgnoreCase(true);
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org