db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Katherine Stone <kathyast...@gmail.com>
Subject addAscendingOrderByColumn method not working
Date Tue, 22 Mar 2005 21:02:15 GMT
Using Torque 3.0

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
Kathy Stone

========schema.xml table entry=========
   <table name="PERSON_REL_VW" javaName="PersonRole">
    	<column name="PERSON_REL_ID" type="DECIMAL" javaName="RoleId"/>
    	<column name="PERSON_REL_PER_ID" size="10" type="INTEGER"
    	<column name="PERSON_REL_ENTITIY_ID" size="10" type="INTEGER"
    	<column name="PERSON_REL_ENTITY_TYPE" size="17" type="VARCHAR"
    	<column name="PERSON_REL_ENTITY_NAME" size="64" type="VARCHAR"
    	<column name="PERSON_REL_REL_DESC" size="64" type="VARCHAR"
=====String defs and relevant method in Person.java=====
	private static final String
	private static final String
	private static final String
	private static final String
	/*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";

			criteria.add(PersonRolePeer.PERSON_REL_PER_ID, getId());
			//addAscendingOrderByColumn throws null pointer exception... ugh
			relList = PersonRolePeer.doSelect(criteria);
			criteria.add(PersonRolePeer.PERSON_REL_PER_ID, getId());
			//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

View raw message