• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we use plain SQL queries in Hibernate?

 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
can we use plain sql queries in hibernate? if so, please let me know how to do it.

Thanks in advance.
--Deepika.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course

SqlQuery query = session.createSqlQuery("sql here");
List<SomeTypeOfEntityHere> results = query.list();

Not really any different than using HQL. I also think you can set it to a type Query and not have to be SqlQuery. Query should be an interface that SqlQuery implements.

Mark
 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the explanation Mark.
--Deepika.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic