I have an POJO with multiple fields. One of the fields is a List. Some of the fields in first POJO will have same values as fields in SecondPojo.
I want to get a List with one query. Whoever wrote the code in the past was getting a List and doing a query to fetch List for each object inside List which defeats the purpose of using a database.
How can I do this in iBatis?
This is the result map I have currently which I assume is correct.
<resultMap id="example" type="FirstPojo">
<id property="headerId" column="id"/>
<result property="field1" column="field_one"></result>
...
<collection property="example2" ofType="SecondPojo">
<id property="versionId" column="id"/>
<result property="field1" column="field_one"></result>
...
</collection>
The question is how do I go on about writing the query? FirstPojo and SecondPojo data are in different tables.
This is what I have right now which isn't working.
Select
h.id as "headerId"
v.field_one as "field1"
v.id as "versionId"
v.field_one as "field1"
FROM account.first_pojo h
JOIN account.second_pojo v