Search code examples
javasqlhibernatehql

how to import a hql project in eclipse


Present scenario: I am trying to use hql in place of sql.

(1)I need to know,In order to use hql what all basic jars or basic setup I will be needing.

I have basic java knowledge,But new to hibernate.

(2) And how to import a hibernate project into eclipse.

For instance i am using eclipse mars.


Solution

  • SQL (Structured Query Language) is a standard query language used by multiple relational database systems. HQL (Hibernate Query Language) is a SQL-like language used by Hibernate, to retrieve and populate objects with data from a relational database. HQL-queries are translated to SQL queries by Hibernate.

    So these are not equivalent by far. In order to even use HQL your application would have to use Hibernate.

    In a Hibernate application, the advantages of HQL is its brevity, the way HQL queries automatically populate entity objects, and the fact that it is database vendor-agnostic (meaning that you should be able to change database provider without changing your queries.) The disadvantages are mainly related to performance, where complex queries/data models might end up slow.

    Using SQL in a Hibernate setting on the other hand has the advantage of being fast, as you control what is being queried in the database, and the disadvantages compared to HQL that you have to do your own database-to-object mappings, as well as being more verbose. In addition, changing database vendors might lead to rewriting your queries.

    Since your use case is that of pure data migration as far as I understand it, I would use SQL as it is a simpler approach to these kind of problems. If you build a data migration application, HQL might be right, but that really depends on your case.

    If you want to use HQL you should start by reading up on JPA and Hibernate.