At my Oracle database I have two example tables:
- tabel
Awith columnsid,a1,a2,a3 - tabel
Bwith columnsid,b1,b2,b3
I have view for get information from this two tables:
CREATE VIEW Foo ("A.id", "A.a1", "A.a2", "A.a3", "B.id", "B.b1", "B.b2", "B.b3") AS
SELECT aaa.*, bbb.*
FROM A aaa, B bbb
WHERE
...some conditions...;
In my Java application I want to get information result by Foo view by Hibernate. So I have to use createSQLQuery() method:
public List<SomeObject> findSomeObjects() {
Query q = sessionFactory.getCurrentSession()
.createSQLQuery("select f.* from Foo f")
.addEntity(A.class).addEntity(B.class);
List l = q.list();
//here I want to get object of A class and B class from return l
//and prepare return list of SomeObject
}
SomeObject is agregate for A and B class.
I have problem with get object of A class and B class from return list and construct SomeObject list. How can I make it properly?
EDIT
- table
Ahave one more columnfk_c, which is foreign key toCtable - table
Bhave one more columnfk_d, which is foreign key toDtabel