• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Criteria API vs HQL

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

What would be the difference between them. Whatever I can do with the Criteria API, I can do with simple HQL. So why would I ever need to use the Criteria API?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you create a syntax error using the Criteria api?
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
Can you create a syntax error using the Criteria api?



What is a syntax error?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An error caused by invalid HQL syntax.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Can you create a syntax error using the Criteria api?



hey bartender, just pass on the information that he asked for .. dont show off.. i think thats not why you are here in javaranch.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Ajeeth, what I was going for was asking a question to lead Jothi to an answer rather than just telling them my opinion (a very old teaching method). But I can see how my response might sound a little curt and, if Jothi didn't think about my question at all, unhelpful.

Internet fora are an environment ripe for misinterpretation, so I will clarify I'm not trying to show off here. But I would remind you that JavaRanch's primary goal is "to help beginners (green horns) learn how to do things themselves" (see this), so where I could have just done as you state I judged it (hopefully) more helpful in the long run to try to get Jothi to think a little about the question they had asked, particularaly as my answer would be an opinion that could be digested in an unqualified way. I suppose I see topics here as a discussion, rather than a simple question/answer.

Now, I don't want you to think I'm piqued here, but I might also point out that there is no obligation on me (or any of the other unpaid volunteers here) to answer any questions posted. Please remember that we ask all participants to BeNice, so I will bear in mind your comments on my response to try to avboid misunderstandings in future and I hope you bear in mind mine next time you post on JavaRanch.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:just pass on the information that he asked for


That is not why we're here at JavaRanch. (With 8 posts, perhaps you're not yet an authority on what JavaRanch is here for?)

Please read NotACodeMill. JavaRanch is a learning site. We're not here just to give out answers, but to teach people how to find them for themselves. Paul's post was a fine way of trying to get Jothi to think through his question and discovers answers on his own.
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Well Ajeeth, what I was going for was asking a question to lead Jothi to an answer rather than just telling them my opinion (a very old teaching method). But I can see how my response might sound a little curt and, if Jothi didn't think about my question at all, unhelpful.

Internet fora are an environment ripe for misinterpretation, so I will clarify I'm not trying to show off here. But I would remind you that JavaRanch's primary goal is "to help beginners (green horns) learn how to do things themselves" (see this), so where I could have just done as you state I judged it (hopefully) more helpful in the long run to try to get Jothi to think a little about the question they had asked, particularaly as my answer would be an opinion that could be digested in an unqualified way. I suppose I see topics here as a discussion, rather than a simple question/answer.

Now, I don't want you to think I'm piqued here, but I might also point out that there is no obligation on me (or any of the other unpaid volunteers here) to answer any questions posted. Please remember that we ask all participants to BeNice, so I will bear in mind your comments on my response to try to avboid misunderstandings in future and I hope you bear in mind mine next time you post on JavaRanch.




Agree that javaranch is NotACodeMill, but your posting was rather curt(atleast I thought so) . When people start posting questions here, I assume that they had done some ground work and are now looking for help in the form of quick answers to get them out of some tight situation . I was myself looking at answering some questions on how to effectively use hibernate formulas to retrieve a logical(but fake ) column and how to use the basic DB relationship to imply P-C relationships across multiple levels of hierarchy using Criteria. Hence the outburst.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:Hence the outburst.

Please avoid future outbursts. They help no one.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:

Paul Sturrock wrote:Well Ajeeth, what I was going for was asking a question to lead Jothi to an answer rather than just telling them my opinion (a very old teaching method). But I can see how my response might sound a little curt and, if Jothi didn't think about my question at all, unhelpful.

Internet fora are an environment ripe for misinterpretation, so I will clarify I'm not trying to show off here. But I would remind you that JavaRanch's primary goal is "to help beginners (green horns) learn how to do things themselves" (see this), so where I could have just done as you state I judged it (hopefully) more helpful in the long run to try to get Jothi to think a little about the question they had asked, particularaly as my answer would be an opinion that could be digested in an unqualified way. I suppose I see topics here as a discussion, rather than a simple question/answer.

Now, I don't want you to think I'm piqued here, but I might also point out that there is no obligation on me (or any of the other unpaid volunteers here) to answer any questions posted. Please remember that we ask all participants to BeNice, so I will bear in mind your comments on my response to try to avboid misunderstandings in future and I hope you bear in mind mine next time you post on JavaRanch.




Agree that javaranch is NotACodeMill, but your posting was rather curt(atleast I thought so) . When people start posting questions here, I assume that they had done some ground work and are now looking for help in the form of quick answers to get them out of some tight situation . I was myself looking at answering some questions on how to effectively use hibernate formulas to retrieve a logical(but fake ) column and how to use the basic DB relationship to imply P-C relationships across multiple levels of hierarchy using Criteria. Hence the outburst.


Your assuming is wrong, you can find many people here asking ranchers to do their own home work and asking for code of their own problem, not to mention many don't even bother to google their question first.
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ajeeth Kumar wrote:

Paul Sturrock wrote:Well Ajeeth, what I was going for was asking a question to lead Jothi to an answer rather than just telling them my opinion (a very old teaching method). But I can see how my response might sound a little curt and, if Jothi didn't think about my question at all, unhelpful.

Internet fora are an environment ripe for misinterpretation, so I will clarify I'm not trying to show off here. But I would remind you that JavaRanch's primary goal is "to help beginners (green horns) learn how to do things themselves" (see this), so where I could have just done as you state I judged it (hopefully) more helpful in the long run to try to get Jothi to think a little about the question they had asked, particularaly as my answer would be an opinion that could be digested in an unqualified way. I suppose I see topics here as a discussion, rather than a simple question/answer.

Now, I don't want you to think I'm piqued here, but I might also point out that there is no obligation on me (or any of the other unpaid volunteers here) to answer any questions posted. Please remember that we ask all participants to BeNice, so I will bear in mind your comments on my response to try to avboid misunderstandings in future and I hope you bear in mind mine next time you post on JavaRanch.




Agree that javaranch is NotACodeMill, but your posting was rather curt(atleast I thought so) . When people start posting questions here, I assume that they had done some ground work and are now looking for help in the form of quick answers to get them out of some tight situation . I was myself looking at answering some questions on how to effectively use hibernate formulas to retrieve a logical(but fake ) column and how to use the basic DB relationship to imply P-C relationships across multiple levels of hierarchy using Criteria. Hence the outburst.



Your first post wasnt so endearing as well. But back to the OP, I assume you would have googled your queries and found a couple of links that answer your question. Is there something in particular?
 
Ajeeth Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apologize for the late reply, but I wanted to post this just for the benefit for new learners.

Criteria can be used in situations like where you have a search screen with multiple conditions to search from, but you dont want to have a complex DAO layer code with complex IF / ELSE conditions .

The advantage of Criteria is it adds and implicit AND condition to the query that would be generated by hibernate. The code will also be much easier to understand and maintain or fix.


 
Don't MAKE me come back there with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic