Hi
I have some question about
Java Progarmming
I attened the DB ERdigram.
The situation is that there are 4 tables which are company , address, contact and location.
A company may contain many address so thier relationship in 1 to many and 1 address may contain many contact so their relationship is also 1 to many and 1 address only contain 1 location so their relationship is 1 t o1.
I want to select all data from these 4 tables by the company Id.
So First I do the first quesry, I select the data from company table join with address table by the company Id.
Aftrer that I want to do the second query to select the data from contact and location table.
Then the problem come out.
How can I get the FK of contact and location from first query in order to do the second query?
I use JDBCTemplate API in my java code
JDBCTemplate only return a object or a arraylist. But I want to have Object Arraylist (or other collection data type ) so that I can loop this ArrayList ( or collection data) to get the FK of contact tabel and location table from address table.
Because I need the 2 PK to do the second query
What method can i get the FK of contact and location (the data) from first query when the first query return a arraylist( a collectiondata )?
I try to casting the result of the arraylist e.g. (Address)resultArraylsit.get(0) in order to get the data in the arraylist.
But it fail
Can anyone help me?