-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Criteria usage
PostPosted: Mon Feb 09, 2004 6:57 pm 
Newbie

Joined: Mon Feb 09, 2004 6:45 pm
Posts: 10
Location: Feltre, BL Italy
Hi all
I'm using Hibernate 2.0.3
I'm getting a list of items out of the persistent store using Criteria.list.
The Criteria instance can be set up with some Expression and/or Order
according to the user input in a suitable dialog.
When I use the Order part only (meaning that I do not want any selection
at all, but I do want the list be sorted), the Criteria.list() method
throws an exception (NullPointerException) A look by some debugger confirms this got raised since the Expression part in null.
So: Should the Expression *AND* the Order part of a Criteria instance
be set in order to get a valid Criteria instance?
Is there any way to use it to get all records, but sorted in the set way
(apart from the trivial solution to set: Expression.sql("SELECT * FROM Item"))?
thanks in advance
davide


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 7:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please show your code.

session.createCriteria(Something.class).addOrder(Order.asc("property"));

should work nicely. Where is your problem?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 7:23 pm 
Newbie

Joined: Mon Feb 09, 2004 6:45 pm
Posts: 10
Location: Feltre, BL Italy
Thank you!
The problem was that sometimes i did something like:
session.createCriteria(Something.class)
.add(expression)
.addOrder(Order.asc("property"));

where expression could be null

Thanks again


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.