[1.2.4] Case insensitive JPA order by

786 views
Skip to first unread message

Spencer Strombotne

unread,
Jun 21, 2012, 10:22:53 AM6/21/12
to play-fr...@googlegroups.com
I've got a "person" JPA object that has a name string. I'm trying to retrieve the people from the database in order by their name. The problem is that some of the people have names that are all lowercase so they always appear at the end of the results. I've tried this:

List<Person> people = Person.find("order by UPPER(name)").fetch();

.. but it doesn't work. It orders all people by name but someone with a lowercase first letter ('adam') still appears after Z 

Anyone have any ideas?

loict

unread,
Jun 21, 2012, 10:44:01 AM6/21/12
to play-fr...@googlegroups.com
it seems it depends on JPA implementation. 


what's yours?

Spencer Strombotne

unread,
Jun 21, 2012, 2:24:22 PM6/21/12
to play-fr...@googlegroups.com
I'm trying the following:

List<Person> people = Person.find("order by LOWER(name)").fetch();

It's returning the same as if I had just done:

List<Person> people = Person.find("order by name").fetch();

So a* still appears after Z*

I'm using the default JPA layer that is packaged with 1.2.4, so hibernate I think.
Message has been deleted

Spencer Strombotne

unread,
Jun 21, 2012, 3:18:06 PM6/21/12
to play-fr...@googlegroups.com
This was my mistake. The data was being sorted again further down the stack that I was unaware of.
Reply all
Reply to author
Forward
0 new messages