I have 2 tables in a one-to-many mapping, layoutFeature
and layoutPadData
.
Parent table layoutFeature
has 2 columns: layoutId
(Pkey) and colorHex
.
Child table layoutPadData
has 5 columns:
layoutId (Fkey), padId (Pkey), longitude, latitude, padName
Now I want to write a query which from database will fetch data like this projection:
public interface LayoutFeatureInfo {
String getColorHex();
List<LayoutPadDataInfo> getPadLevelDataList();
interface LayoutPadDataInfo {
double getLatitude();
double getLongitude();
String getPadName();
}
}
I wrote this query :
But this doesn't work since the query returns:
All rows of layoutPadData table but I want selective of them under padLabelDataList
As I had done join, I get multiple rows of colorHex as well but I what I want is single property of parent and list of child interface something like this will be response of api when I fetch from DB:
Can anyone help me with the query please.