hi I am working on HQL queries and writing an application in Java it is just in development phase so I am using a dummy database.
But I am having troubles with displaying result using HQL queries.
/**
* Displays a report listing all companies that have no departments.
*/
public void displayCompaniesWithoutDepartments() {
System.out.println("---- All Companies Without Departments ----");
Session session = sessions.getCurrentSession();
session.beginTransaction();
Query q = session.createQuery("select comp.id , comp.name from Department as dept left outer join dept.Company as comp");
List result = q.list();
for (Object object : result){
Company company = (Company) object;
System.out.println(company.getName());
}
session.getTransaction().commit();
// Finish this
}
I know some part of my function is incorrect but at first the query is not running it self I have search on google It seems to be in the right order but I dont understand what is the problem.
I get this error
Error: could not resolve property: company_id of: Department
when department has many to one relation ship with Company.