Well, joins, being the primary operation supported by relation databases, shouldn't cause you much trouble. Especially if you join on primary key. If you don't, and your application doesn't belong to most apps where joining two tables is a non-issue, proper indexing (after you've done some analysis on why your query is slow) will certainly help.
If it doesn't -- you've still got a lot of choices which I won't cover here.
Thanks Alin. The solution worked. :)
But I was just wondering if applying a join on the 2 tables would be okay.
If i have to fetch quite a number of fields, then wouldn't the join be a
Alin Popa wrote:
> Hi Babitha,
> Hopefully that I understand right your issue, so, here is how I made it
> I think also this is the iBatis way to handle it)
> <sqlMap namespace="MyObject">
> <resultMap id="result" class="org.test.MyObject" groupBy="id">
> <result property="id" column="id" columnIndex="1" />
> <result property="name" column="name" columnIndex="2" />
> <result property="details" column="details" columnIndex="3" />
> <result property="properties" resultMap="MyObject.resultProperty"
> <resultMap class="org.test.Property" id="resultProperty">
> <result property="objId" column="obj_id" />
> <result property="name" column="property_name" />
> <result property="value" column="property_value" />
> <select id="getMyObjects" resultMap="result"
> SELECT obj.id as id, obj.name, obj.details, p.id as property_id,
> p.obj_id as obj_id, p.name as property_name, p.value as property_value
> FROM objects obj LEFT JOIN properties p
> ON obj.id = p.obj_id WHERE obj.id=#id#
> On Mon, Jun 1, 2009 at 3:39 PM, Babitha <Babitha.Sridhar@ge.com> wrote:
>> I have a Dealer bean. The Dealer bean contains a List of DealerContact
>> objects. I would have to execute 2 select queries to populate Dealer bean
>> and DealerContact bean. I wish to execute both the select queries in one
>> such that all the details of Dealer bean including DealerContact property
>> gets populated. But my DealerContact list returns null.
>> I have attached the Dealer bean, DealerContact bean and the xml file
>> containing the queries. Please help me in finding out where I am going
>> I am making the iBatis call using the below code:
>> List dealerDetailsList =
>> getSqlMapClientTemplate().queryForList("selectDealerDetails", dealer);
>> Thanks in advance for the help extended.
>> - Babitha http://www.nabble.com/file/p23814348/sqlDatabaseQueries.xml
>> sqlDatabaseQueries.xml http://www.nabble.com/file/p23814348/Dealer.java
>> Dealer.java http://www.nabble.com/file/p23814348/DealerContact.java
>> View this message in context:
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
View this message in context: http://www.nabble.com/Populate-List-within-object-in-iBatis-tp23814348p23827424.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.