-->
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: Querying the database
PostPosted: Tue Apr 18, 2006 5:59 pm 
Regular
Regular

Joined: Sun Feb 12, 2006 10:18 pm
Posts: 60
Location: Rosario, Argentina
I've seen MANY different ways to query a database...

    session.Find
    session.CreateCriteria
    session.CreateQuery

and also some different ways to make the querystring when parameters are needed

    "p.Id = ?"
    "p.Id = :IdNumber"
    "p.Id = {0}"


what I wanted to know is what is the difference in all this cases.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 8:01 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Ref docs help with this stuff.
For the query types:
- Find is on its way out: Hibernate has already removed it, and future versions of NHibernate probably won't have it. If you use it, be prepared to refactor your code later.
- CreateCriteria uses Criteria, which is most useful if your query is to be generated at run time.
- CreateQuery uses HQL, which is most useful if your query doesn't change (only its parameters do).

For the parameters, see section 10.4.1.4 (of the 3.1 ref docs).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 19, 2006 8:58 am 
Regular
Regular

Joined: Sun Feb 12, 2006 10:18 pm
Posts: 60
Location: Rosario, Argentina
I was looking to the NHibernate documentation... that didn't help much. Here's an idea: why don't you create a documentation like the one in msdn, wich has language filter? that way, you have only one doc for both Hibernate and NHibernate, but where things are different you create both ways and the filter only shows the one that the user desires...
But I must say that the whole forum is great, whenever I have a question or a problem, I know I can find the answer here. And I see that Hibernate's documentation is quite complete (although it doesn't sat anything about "Find" going out... maybe it doesn't even exist in Hibernate?)

Thanks a lot, Tenwit!


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.