I'm developing rest api server with java, mybatis.
There is one issue on my mind with select some data. I don't know which one is reasonable or better way for server and developer.
Please let me hear your opinions.
This data has to be returned by a method. First one is using a lot of select methods in mapper.xml and mapper.java like below
<select id="a" resultType="Integer" parameterType="ParameterMap">
select a from a where a=a
</select>
<select id="b" resultType="Integer" parameterType="ParameterMap">
select b from b where b=b
</select>
<select id="c" resultType="Integer" parameterType="ParameterMap">
select c from c where c=c
</select>
.....
And the other way is merging select sentence on one select method like below.
<select id="abc" resultType="Integer" parameterType="ParameterMap">
select a
,(select b from b where b=b)
,(select c from c where c=c)
....
from a where a=a
</select>
I guess connect to database could use lots of resources, so second one is better way. However on the other hand, maybe following second way makes hard to maintain the code.
What do you think is a better way?