Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 65349 invoked from network); 22 Mar 2005 21:11:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2005 21:11:55 -0000 Received: (qmail 1754 invoked by uid 500); 22 Mar 2005 21:11:50 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 1701 invoked by uid 500); 22 Mar 2005 21:11:50 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 1634 invoked by uid 99); 22 Mar 2005 21:11:49 -0000 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=NO_REAL_NAME,UPPERCASE_25_50 X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from hoespc01.exxonmobil.com (HELO hoespc01.exxonmobil.com) (192.67.48.38) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 22 Mar 2005 13:11:49 -0800 Received: from hounmg03.NA.XOM.COM (hounmg03.na.xom.com [158.35.101.41]) by hoespc01.exxonmobil.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id j2MLBjXK022960 for ; Tue, 22 Mar 2005 15:11:45 -0600 (CST) Subject: Re: addAscendingOrderByColumn method not working To: "Apache Torque Users List" X-Mailer: Lotus Notes Release 5.0.3 (Intl) 21 March 2000 Message-ID: From: adam.s.allgaier@exxonmobil.com Date: Tue, 22 Mar 2005 15:11:42 -0600 X-MIMETrack: Serialize by Router on Hounmg03.na.xom.com/S/ExxonMobil(652HF702|December 14, 2004) at 03/22/2005 03:11:45 PM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Try changing these: private static final String SORT_ENTITY_TYPE_COL="PersonRolePeer.PERSON_REL_ENTITY_TYPE"; private static final String SORT_ENTITIY_ID_COL="PersonRolePeer.PERSON_REL_ENTITIY_ID"; private static final String SORT_ENTITY_NAME_COL="PersonRolePeer.PERSON_REL_ENTITY_NAME"; private static final String SORT_ROLE_DESC="PersonRolePeer.PERSON_REL_REL_DESC"; to this (remove all the ") : private static final String SORT_ENTITY_TYPE_COL=PersonRolePeer.PERSON_REL_ENTITY_TYPE; private static final String SORT_ENTITIY_ID_COL=PersonRolePeer.PERSON_REL_ENTITIY_ID; private static final String SORT_ENTITY_NAME_COL=PersonRolePeer.PERSON_REL_ENTITY_NAME; private static final String SORT_ROLE_DESC=PersonRolePeer.PERSON_REL_REL_DESC; This will guarantee that you are using the generated table.column_name strings. Adam Katherine Stone cc: Subject: addAscendingOrderByColumn method not working 03/22/05 03:02 PM Please respond to "Apache Torque Users List" Using Torque 3.0 Hello, I have read over the various posts concerning addDescendingOrderByColumn method not working when building a Criteria object. If I do not include the addDescendingOrderByColumn or addAscendingOrderByColumn, the sql works fine(but does not order of course). When I add it back, a NullPointerException is thrown when doSelect() is executed. The column I am sorting on is a String. I noticed when stepping through in debug mode, right after the criteria.add(PersonRolePeer.PERSON_REL_PER_ID, getId()); , the Criteria object inspection correctly prints out a select statement, but after executing the addAscendingOrderByColumn line, the criteria select statement seems blank. Per the past posts: I checked and the db name is set in the schema.xml. The db adapter is also correct in the torque.properties file. As you can see, in the commented out code , I tried a work around of a custom criteria which I didn't get working yet either. I'd really like to use the torque method though instead of a custom criteria. Any ideas? Thanks, Kathy Stone ========schema.xml table entry=========
=====String defs and relevant method in Person.java===== private static final String SORT_ENTITY_TYPE_COL="PersonRolePeer.PERSON_REL_ENTITY_TYPE"; private static final String SORT_ENTITIY_ID_COL="PersonRolePeer.PERSON_REL_ENTITIY_ID"; private static final String SORT_ENTITY_NAME_COL="PersonRolePeer.PERSON_REL_ENTITY_NAME"; private static final String SORT_ROLE_DESC="PersonRolePeer.PERSON_REL_REL_DESC"; /*private static final String SORT_ENTITY_TYPE_COL="PERSON_REL_ENTITY_TYPE"; private static final String SORT_ENTITIY_ID_COL="PERSON_REL_ENTITIY_ID"; private static final String SORT_ENTITY_NAME_COL="PERSON_REL_ENTITY_NAME"; private static final String SORT_ROLE_DESC="PERSON_REL_REL_DESC";*/ ......... public List getRels(String sortOrder, String sortCol) throws TorqueException{ List relList=null; Criteria criteria = new Criteria(); String sortColName = SORT_ENTITY_TYPE_COL; if (sortCol.equalsIgnoreCase("EntityType")) sortColName = SORT_ENTITY_TYPE_COL; else if(sortCol.equalsIgnoreCase("RelatedTo")) sortColName = SORT_ENTITIY_ID_COL; else if(sortCol.equalsIgnoreCase("Description")) sortColName = SORT_ENTITY_NAME_COL; else if(sortCol.equalsIgnoreCase("Relationship")) sortColName = SORT_ROLE_DESC; //String sortOrderStrAsc = "ORDER BY " + sortColName + " ASC"; //String sortOrderStrDesc = "ORDER BY " + sortColName + " DESC"; if(sortOrder.equalsIgnoreCase("A")){ criteria.add(PersonRolePeer.PERSON_REL_PER_ID, getId()); //criteria.add(PersonRolePeer.PERSON_REL_PER_ID,(Object)sortOrderStrAsc, Criteria.CUSTOM); //addAscendingOrderByColumn throws null pointer exception... ugh criteria.addAscendingOrderByColumn(sortColName); relList = PersonRolePeer.doSelect(criteria); }else { criteria.add(PersonRolePeer.PERSON_REL_PER_ID, getId()); criteria.addDescendingOrderByColumn(sortColName); //criteria.add(PersonRolePeer.PERSON_REL_PER_ID,(Object)sortOrderStrDesc, Criteria.CUSTOM); relList = PersonRolePeer.doSelect(criteria); } return relList; } --------------------------------------------------------------------- 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