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 Subadhra Jagannathan <su...@gmail.com> on 2008/03/28 00:24:39 UTC

Uppercase column names throwing a null pointer access in addAscendingOrderByColumn()

Hello all,

I hope someone can help me/point me to what I am doing wrong.

If do these query in mySQL query browser --

select person.PERSON_ID from person where person.PERSON_ID > 100
order by person.PERSON_ID asc;

select person.person_id from person where person.person_id > 100
order by person.person_id asc;

both works, so I know my sql is not case sensitive on column names.

But if I use criteria, among the following functions (below),
testCrit() and testCrit1() both works fine, but the testCrit2() with the
uppercase col name in the addAscendingOrderByColumn() fails with the null
pointer exception.

This was working in Torque 3.2. Can some one point me what is it that I am
doing wrong?

Thanks a lot.
Subadhra


public void testCrit() throws Exception {
        Criteria crit = new Criteria();
        crit.addSelectColumn(PersonPeer.PERSON_ID);
        crit.add(PersonPeer.PERSON_ID, 100, Criteria.GREATER_THAN);
        crit.addAscendingOrderByColumn(PersonPeer.PERSON_ID);
        List list = BasePeer.doSelect(crit);
        System.out.println(list.size());
    }

    public void testCrit1() throws Exception {
        Criteria crit = new Criteria();
        crit.addSelectColumn("person.person_id");
        crit.add("person.person_id", 100, Criteria.GREATER_THAN);
        crit.addAscendingOrderByColumn("person.person_id");
        List list = BasePeer.doSelect(crit);
        System.out.println(list.size());
    }

    public void testCrit2() throws Exception {
        Criteria crit = new Criteria();
        crit.addSelectColumn("person.person_id");
        crit.add("person.person_id", 100, Criteria.GREATER_THAN);
        crit.addAscendingOrderByColumn("person.PERSON_ID");
        List list = BasePeer.doSelect(crit);
        System.out.println(list.size());
    }

RE: Uppercase column names throwing a null pointer access in addAscendingOrderByColumn()

Posted by Thomas Fischer <fi...@seitenbau.net>.
a) Please use the constants defined in the generated Peer classes whereever
possible. Using the constants is considered good style.

b) I do not remember in detail, but it may be that case preserving policy
from schema.xml to db and/or Templates hase changed. Check the constants
for column names in the 3.2 generated peer class and the 3.3 generated peer
class against each other.
Torque uses exact case-sensitive matches to find columns in its internal
model, so if you use wrong case, you might run into trouble, indifferent of
whether the database is case-independent or not.

      Thomas

"Subadhra Jagannathan" <su...@gmail.com> schrieb am
28.03.2008 00:24:39:

> Hello all,
>
> I hope someone can help me/point me to what I am doing wrong.
>
> If do these query in mySQL query browser --
>
> select person.PERSON_ID from person where person.PERSON_ID > 100
> order by person.PERSON_ID asc;
>
> select person.person_id from person where person.person_id > 100
> order by person.person_id asc;
>
> both works, so I know my sql is not case sensitive on column names.
>
> But if I use criteria, among the following functions (below),
> testCrit() and testCrit1() both works fine, but the testCrit2() with the
> uppercase col name in the addAscendingOrderByColumn() fails with the null
> pointer exception.
>
> This was working in Torque 3.2. Can some one point me what is it that I
am
> doing wrong?
>
> Thanks a lot.
> Subadhra
>
>
> public void testCrit() throws Exception {
>         Criteria crit = new Criteria();
>         crit.addSelectColumn(PersonPeer.PERSON_ID);
>         crit.add(PersonPeer.PERSON_ID, 100, Criteria.GREATER_THAN);
>         crit.addAscendingOrderByColumn(PersonPeer.PERSON_ID);
>         List list = BasePeer.doSelect(crit);
>         System.out.println(list.size());
>     }
>
>     public void testCrit1() throws Exception {
>         Criteria crit = new Criteria();
>         crit.addSelectColumn("person.person_id");
>         crit.add("person.person_id", 100, Criteria.GREATER_THAN);
>         crit.addAscendingOrderByColumn("person.person_id");
>         List list = BasePeer.doSelect(crit);
>         System.out.println(list.size());
>     }
>
>     public void testCrit2() throws Exception {
>         Criteria crit = new Criteria();
>         crit.addSelectColumn("person.person_id");
>         crit.add("person.person_id", 100, Criteria.GREATER_THAN);
>         crit.addAscendingOrderByColumn("person.PERSON_ID");
>         List list = BasePeer.doSelect(crit);
>         System.out.println(list.size());
>     }


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org