Hello,
I new to IBatis and for a small project of mine I'm using only the
datamapper framework from Ibatis.
I have a fairly simple data structure where a notebook contains several
pages.
For simplicity assume this domainmodel:
Notebook Page
[id] 1 -> N [id]
The corresponding Map looks like this ( this is not a complete example
as I only want to make clear what my situation is)
<resultMap class="notebook" groupBy="id" id="notebookResult">
<result column="NB_ID" jdbcType="VARCHAR" property="id"/>
<result javaType="java.util.List" property="pages"
resultMap="Note.pageResult"/>
</resultMap>
<resultMap class="page" groupBy="id" id="pageResult">
<result column="P_ID" jdbcType="VARCHAR" property="id"/>
</resultMap>
I'm using the following select statement to get the notebooks and
corresponding pages
<select id="selectNotebook" parameterClass="java.lang.String"
resultMap="notebookResult">
SELECT nb.id as nb_id, p.id as p_id,
FROM notebook nb LEFT JOIN page p ON nb.id = p.notebook_id
WHERE nb.id = #id#
</select>
When I have a notebook that has no pages IBatis sets a page object with
ID = null in the pages property of notebook.
I need to get notebooks that do not have pages but in those cases I do
not wish to have a page object at all.
Is there an easy way around this situations? I have tried to Google and
looked at the archive but all the threads that I found dealing with this
didn't give me any information on how this is solved.
Thanks for any help
Regards
Stefan