-->
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.  [ 2 posts ] 
Author Message
 Post subject: criteria interface
PostPosted: Tue Feb 19, 2008 12:35 am 
Newbie

Joined: Tue Feb 19, 2008 12:29 am
Posts: 2
how to write query in criteria interface ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 10:44 am 
Newbie

Joined: Fri Apr 21, 2006 10:35 am
Posts: 13
Location: de
With the Criteria interface, you don't write HQL or SQL queries. Instead you have Java method calls.

EXAMPLE:
Let's say you have a class "Customer" with an attribute "name", and you want to find all customers called Smith:
Code:
Criteria criteria = session.createCriteria(Customer.class)
                    .add(Restrictions.eq("name", "Smith"));
List smiths = criteria.list();

That puts a list of Customer objects into the "smiths" variable.

Please read the Hibernate API documentation for details.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.