How to test HQL queries?

With Intellij IDEA 8.1.3 the mechnism of choice is called ‘Facet’. To instantly test HQL queries: create a data source Tools -> Data Source, Add Data Source, define driver, username and password of yor development db in case you dont have already a hibernate.cfg or you configure your session factory in a different way than … Read more

passing list to IN clause in HQL or SQL?

from AUTOS a where a.model in (select m.model from MODELS m) or Query query1 = session.createQuery(“select s.id from Salary s where s.salary < 50000 AND s.salary > 49980”); Query query2 = session.createQuery(“from Employee e where e.id in (:ids)”).setParameterList(“ids”, query1.list()); query2.list();

HQL left join of un-related entities

Currently, the theta-style on joining the unrelated classes in the where clause using HQL only supports inner join. The request for supporting the outer join for such situation is currently the 3-rd most voted enhancement but I don’t think this feature will be implemented in the near feature as it requires the re-implementation of the … Read more

One-To-Many relationship gets duplicate objects without using “distinct”. Why?

This question is thoroughly explained on Hibernate FAQ: First, you need to understand SQL and how OUTER JOINs work in SQL. If you do not fully understand and comprehend outer joins in SQL, do not continue reading this FAQ item but consult a SQL manual or tutorial. Otherwise you will not understand the following explanation … Read more

Hive cluster by vs order by vs sort by

A shorter answer: yes, CLUSTER BY guarantees global ordering, provided you’re willing to join the multiple output files yourself. The longer version: ORDER BY x: guarantees global ordering, but does this by pushing all data through just one reducer. This is basically unacceptable for large datasets. You end up one sorted file as output. SORT … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)