You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ashish Kulkarni <ku...@yahoo.com> on 2006/03/01 16:16:28 UTC

Best way to define java class for mapping

Hi
What is the best way to design java class for mapping,
for example suppose i have a SQL querry which join 2-3
tables and returns the data, 
should i design java class to match this SQL querry,
or should i design java class to match tables, and
then create a Map in xml file and then populate data
in 2-3 tables.

Is there a utility which will create java class from
resultset, 
or is there any utility where i may not have to create
java class, like DynaActionForm in struts

ashish

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

RE: Best way to define java class for mapping

Posted by "Fullam, Jonathan, ALABS" <jf...@att.com>.
Hello Ashish,
Regarding a way to not have to create a java class for your result class, you could very easily just set your resultClass to a java.util.HashMap.  This will be popultated for any results for the key being the name of the field being returned and the value being the value.

As far as the "best way to design" your java classes for mapping; My opinion is that you should try to not let your current database design dictate how your object model will look.  Design your java objects in a way that makes sense from an object oriented point of view.  Decide what makes the best sense in terms of what objects you will need perform your business logic.

-Jonathan

-----Original Message-----
From: Ashish Kulkarni [mailto:kulkarni_ash1312@yahoo.com]
Sent: Wednesday, March 01, 2006 10:16 AM
To: user-java@ibatis.apache.org
Subject: Best way to define java class for mapping


Hi
What is the best way to design java class for mapping,
for example suppose i have a SQL querry which join 2-3
tables and returns the data, 
should i design java class to match this SQL querry,
or should i design java class to match tables, and
then create a Map in xml file and then populate data
in 2-3 tables.

Is there a utility which will create java class from
resultset, 
or is there any utility where i may not have to create
java class, like DynaActionForm in struts

ashish

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com