SELECT emp.employeeId, emp.employeeFirstName, comp.companyname, dept.departmentname
FROM Employeetable emp, Companytable comp, departmenttable dept
WHERE emp.employeeCompanyId=comp.companyId AND emp.EmployeeDepartmentID=dept.DepartmentID;
Файл hbm для сотрудника:
<sql-query name="callrealtimeprocedure">
<return alias="employeetable" class="com.AdiSys.eRMS.entity.Employeetable"/>
<return-join alias="companytable" property="com.AdiSys.eRMS.entity.Employeetable"/>
<return-join alias="companytable" property="com.AdiSys.eRMS.entity.Employeetable"/>
</sql-query>
pojo сотрудника:
@NamedNativeQueries({
@NamedNativeQuery(
name = "callrealtimeprocedure",
query = "CALL realtime(:employeeId,:employeeFirstName)",
resultClass = Employeetable.class
)
})
@Entity
Аналогично отделу hbm и pojo.
Мой Java-класс после создания сеанса:
Query EmplyeeQuery = session.createSQLQuery("CALL realtime(:employeeId,:employeeFirstName,:companyname,:departmentname)")
.addEntity(Employeetable.class)
.addEntity(Companytable.class)
.addEntity(Departmenttable.class)
.setParameter("employeeId", "")
.setParameter("employeeFirstName","")
.setParameter("companyname", "")
.setParameter("departmentname", "");
Я не могу выяснить, как связать SQL-запрос хранимой процедуры в hbm, pojo и java-классе