Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5962365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:05:43+00:00 2026-05-22T19:05:43+00:00

I have a very silly doubt in NHibernate. There are two or three entities

  • 0

I have a very silly doubt in NHibernate. There are two or three entities of which two are related and one is not related to other two entities. I have to fetch some selected columns from these three tables by joining them. Is it a good idea to use session.CreateSql() or we have to use session.CreateCriteria(). I am really confused here as I could not write the Criteria queries here and forced to use CreateSql. Please advise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:05:44+00:00Added an answer on May 22, 2026 at 7:05 pm

    in general you should avoid writing SQL whenever possible;
    one of the advantages of using an ORM is that it’s implementation-agnostic.
    that means that you don’t know (and don’t care) what the underlying database is, and you can actually switch DB providers or tweak with the DB structure very easily.
    If you write your own SQL statements you run the risk of them not working on other providers, and also you have to maintain them yourself (for example- if you change the name of the underlying column for the Id property from ‘Id’ to ‘Employee_Id’, you’d have to change your SQL query, whereas with Criteria no change would be necessary).

    Having said that- there’s nothing stopping you from writing a Criteria / HQL that pulls data from more than one table. for example (with HQL):

    select emp.Id, dep.Name, po.Id  
    from Employee emp, Department dep, Posts po
    where emp.Name like 'snake' //etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very small silly doubt . i have a line <%= select_tag
Its a very silly problem but somehow it is not working I have a
Ok, I have a very silly question to ask (which Im rather embaressed about
This may seem a very silly question. Consider this: I have a simple Boolean
Very simple + silly question: Does clojure provide multi maps? I currently have something
I have very very big html page/data. I need to fetch data under h1
I have very simple window where I have 2 buttons - one for cancel,
I am new to Swing. There is a silly question that I have. It
This could be very silly... If I have such a template class A, template
I'm starting learning JAXB, so my question can be very silly. Now I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.