ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Pitts" <Daniel.Pi...@cnet.com>
Subject RE: Populating existing beans...
Date Tue, 12 Sep 2006 20:49:22 GMT
To clarify more,
I have a bunch of beans of different classes.  There is a table for each
class of bean, with columns that correspond directly to bean properties.
This makes it easy to do things like <select id="getAuthors"
resultClass="author">SELECT * from authors</select>
What I'd like to do is something like
<select id="getSomething" resultClass="$resultClass$"
remapResults="true">SELECT * FROM $table$</select>


From: Daniel Pitts [mailto:Daniel.Pitts@cnet.com] 
Sent: Tuesday, September 12, 2006 1:42 PM
To: user-java@ibatis.apache.org
Subject: RE: Populating existing beans...

Thanks for the reply.
 I'm well aware of queryForMap, but the problem isn't grouping the
Basically, I have a bean "graph" (or tree, or whatever) that has been
constructed before there is enough information to run the final query.
Also, I don't know the bean class before hand (and don't want to add it
explicitly to the resultMap or resultClass argument)
As an alternative solution to my problem, if there was a way to do a
queryForList, but specify the result class at runtime, that would be
extremely helpful.


From: Adediran.Ayandele@Sun.COM [mailto:Adediran.Ayandele@Sun.COM] 
Sent: Tuesday, September 12, 2006 1:24 PM
To: user-java@ibatis.apache.org
Subject: Re: Populating existing beans...

Daniel, there is queryForMap functionality in iBatis.  It looks like
this: SqlMapExecutor.queryForMap(statementName, parameterObject, key).
The key will be a column in your result map which could be your bean.id
property after the result map populates the bean.  I am not sure what
you mean by populating existing beans, but I hope this helps.


Daniel Pitts wrote: 

	I have a 
	Map<Integer, MyBean> byId;
	Which was built by "byId.put(myBean.getId(), myBean);"
	MyBean is the base class, there are many types of "MyBean"
	Is there a away to tell iBATIS to use the bean in "byId" map as
	result object? Or do I have to get the result, and copy the
values over
	I know it can be done with queryForObject(String, Object,
Object); but I
	need it for something like queryForList or queryForMap

View raw message