commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip, Anil - Kansas City, MO" <anil.phi...@kcc.usda.gov>
Subject RE: Commons Dbutils: Request feedback for possible patch; handling nested beans.
Date Wed, 22 Jul 2009 16:59:35 GMT

Here is the example - I had an idea and implemented a possible fix that works. I would like
to know before I submit a patch, whether it really is a solution or if there is a better way.
In short, can I get feedback here?   
--------
Problem:
Some of our beans contain object references to other beans. Those nested beans may have properties
that are intended to be filled in by one or more fields from a query. However, since it is
not on the surface, Dbutils cannot find where the property is and so the nested property remains
unfilled.

Example:
Consider a table Moods to track our demeanor while we engage in an activity. So it has two
columns; face (demeanor) and activity.

Face		Activity
-----       --------
huffing	Jog
smile		Work
engrossed	movie
sad		Cry
distant	distracted
bored		waiting

Bean Foo contains an object reference to an instance - a bean- of class Bar. Foo contains
data field or property 'face', and Bar contains the property 'activity', that we want to fill
from this query:
"select face, activity from Mood"

public class Foo {
	private String face;
	private Bar bar;
	public String getFace() {return face;}
	public void setFace(String face) {this.face = face;}
	public void setBar(Bar bar) {this.bar = bar;}
	public Bar getBar() {return bar;}
}
public class Bar {
	private String activity;
	public String getActivity() {return activity;}
	public void setActivity(String activity) {this.activity = activity;}
}

Old way:
QueryRunner runner = new QueryRunner();
BeanHandler bh = new BeanHandler(Foo.class);
Foo foo = (Foo) runner.query(connection,
	"select face, activity from Mood", bh);

Result: 
Foo.bar is null and its fields are unpopulated.

thanks,
Anil Philip

-----Original Message-----
From: Dan Fabulich [mailto:dan@fabulich.com] 
Sent: Tuesday, July 21, 2009 7:13 PM
To: Commons Developers List
Subject: Re: Commons Dbutils: Request feedback for possible patch; handling nested beans.


Philip, Anil - Kansas City, MO wrote:

> We use dbutils in my team and found a problem when a bean has nested object references.
> The properties in the nested bean are obviously not filled in.

File a bug with an example?  I'm not sure I quite understand your 
scenario.

http://issues.apache.org/jira/browse/DBUTILS
(You need to login to file a bug.)

-Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message