一、HQL 檢索方式
以雙向的一對多來測試 HQL 檢索方式。以 Department 和 Employee 為例。
建表語句:
CREATE TABLE department ( dept_id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, dept_name VARCHAR(50) );CREATE INDEX FK_8hf3vewo7w3v9doungcc51wwy ON department (dept_id);
CREATE TABLE employee ( emp_id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, emp_name VARCHAR(50), salary FLOAT, dept_id_fk INT(11), CONSTRAINT FK_miun1wlqp4ujpsgfshyfi7g9j FOREIGN KEY (dept_id_fk) REFERENCES department (dept_id) );CREATE INDEX FK_miun1wlqp4ujpsgfshyfi7g9j ON employee (dept_id_fk);