commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Mistroni" <mmistr...@waersystems.com>
Subject RE: DynaBeans and ResultSetDynaClass
Date Fri, 13 Aug 2004 12:17:54 GMT
Hello,
	Can it be this the source of the problem?
        
DynaBean row = (DynaBean) it.next();
DynaBean rowCopy = bdc.newInstance();
PropertyUtils.copyProperties(row, rowCopy);
        
I guess when u use copyProperties the destination come
First, and the source second....

Thus rowcopy does not get populated correctly

Hope this helps

Regards
	marco



-----Original Message-----
From: vccarvalho [mailto:vccarvalho@bol.com.br] 
Sent: 13 August 2004 12:52
To: commons-user
Subject: DynaBeans and ResultSetDynaClass

 Hi there! I'm using dynabeans and resultSetDynaClass to
retreive a resultset from a database. As the sources of
this classes are very rare, I got my self into a
problem. Here's some line of code:


        ResultSetDynaClass rsdc = new
ResultSetDynaClass(rs);
        DynaProperty properties[] =
rsdc.getDynaProperties();
        BasicDynaClass bdc = new
BasicDynaClass("dynaBean", BasicDynaBean.class, properties);
        Iterator it = rsdc.iterator();
        try {
            while (it.hasNext()) {
                DynaBean row = (DynaBean) it.next();
                DynaBean rowCopy = bdc.newInstance();
                PropertyUtils.copyProperties(row, rowCopy);
                results.add(rowCopy);
            }
        }



The SQL statement is the following : "SELECT id_forum,
theme, status FROM forum".

And then I try to use this in this way:


Collection cll = queryRunner.executeDynaQuery(query,
dataSource);
            Iterator it = cll.iterator();
            while(it.hasNext()){
                DynaBean forum = (DynaBean)it.next();
               
System.out.println(forum.get("theme").toString());
            }



But I'm getting a null pointer exception. When I debug,
I noticed that the collection comes with all results
expected (in numbers). The Hashtable inside the object
do have the properties (theme, id_forum and so on) but
they all have null values.
Any ideas????

Thanks a lot

Vinicius Carvalho
 
________________________________________________________________________
__
Acabe com aquelas janelinhas que pulam na sua tela.
AntiPop-up UOL - É grátis!
http://antipopup.uol.com.br/



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


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


Mime
View raw message