commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip, Anil - Kansas City, MO" <>
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?   
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

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) { = 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: is null and its fields are unpopulated.

Anil Philip

-----Original Message-----
From: Dan Fabulich [] 
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 
(You need to login to file a bug.)


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message