Tenho as seguintes tabelas:
CREATE TABLE student (
student_id INTEGER PRIMARY KEY auto_increment,
name VARCHAR(250),
dado VARCHAR(100),
house INTEGER
);
CREATE TABLE house (
house BIGINT PRIMARY KEY auto_increment,
name VARCHAR(250) UNIQUE NOT NULL
);
Com este HQL eu obtenho os dados das tabelas nesta ordem:
[code]Query select = sessao.createQuery("FROM House");
List todos = select.list();
System.out.println("Objeto: " + todos.get(0).toString());
for(int i = 0; i < todos.size(); i++){
House house = (House) todos.get(i);
System.out.println("Houses: " + house.getId() + " " + house.getName());
for(Student s : house.getStudents())
System.out.println("Students: " + s.getId() + " " + s.getName());
}
Houses: 15 lar
Students: 11 joao
[/code]
Como eu poderia fazer uma consulta com o seguinte parametro:
select s.name, h.name from student s, house h where s.id = h.id;