1

In my Project iam about to use Hibernate but one create confusion is:

That I Read somewhere:

Hibernate has its own query language, i.e hibernate query language which is database independent So if we change the database, then also our application will works as HQL is database independent HQL contains database independent commands

Does it means that we dont have to write stored proceedure and views while using Hibernate in java?

easwee
  • 15,757
  • 24
  • 60
  • 83
user2983355
  • 53
  • 2
  • 10

1 Answers1

3

Short answer: You dont have to write any query and/or stored procedure. (Also you can hibernate tell to create/update all required tables for you, during application start.)

Long answer: Hibernate can be used without any manual definition of a query. (Using the EntityManager, you can simple tell hibernate to get everything of user.class from the database.) However it does support HQL as well as SQL-Queries, also.

SQL Queries of course will stop to work, when you switch to another database later on. HQL will work for every Database, because hibernate is able to translate HQL Queries to any (of the supported) Database Languages.

But be aware: In my Opinion Hibernate is damn slow if you let hibernate do all the work. (Hibernate fires a LOT of single Select Queries, when loading entities with complex relations)

dognose
  • 20,360
  • 9
  • 61
  • 107
  • Then what is the advantage of hibernate – user2983355 Feb 20 '14 at 13:14
  • 1
    @user2983355 if you don't have to take care about the database, you can develop applications faster. Also *using* the defined java-entities does NOT require any knowledge about database-items and/or their relations. You don't have to mind about column names or generel database layout. – dognose Feb 20 '14 at 15:48