You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Marc Lustig <ma...@marclustig.com> on 2003/01/14 13:31:52 UTC

how to map Peer.field-name --> BO-member

Hi,
I'm simply trying to get a field from a torque-object by field-name.
How is this done?

More specifically, how do I actually map between the member of the BO and
the name of the field?

An example:
ProductPeer has: public static final String ORT; // the field name
Product has member: private byte ort=0;

What I need is a method in Product that looks like this:
Object getMemberByFieldName(String fieldname); // fieldname should refer to
ProductPeer

in my case: getMemberByFieldName("ORT") should return product.ort;

Can somebody please advise me about a solution that is available?

Remark: BaseObject.getByName(java.lang.String field) does not contain any
generic functionality at all.

Thanks in advance.
Marc


Re: how to map Peer.field-name --> BO-member

Posted by "Peter S. Hamlen" <ph...@mail.com>.
I'm using Torque-b3 so it may be different on your version, but it
should just be:

Product.getByName("ORT");
or 
Product.getByPeerName(ProductPeer.ORT);

Note:  these functions return an Object (eg, an Integer instead of an
int)

Look in the generated code in BaseProduct.

Hope this helps.
-Peter

On Tue, 2003-01-14 at 07:31, Marc Lustig wrote:
> Hi,
> I'm simply trying to get a field from a torque-object by field-name.
> How is this done?
> 
> More specifically, how do I actually map between the member of the BO and
> the name of the field?
> 
> An example:
> ProductPeer has: public static final String ORT; // the field name
> Product has member: private byte ort=0;
> 
> What I need is a method in Product that looks like this:
> Object getMemberByFieldName(String fieldname); // fieldname should refer to
> ProductPeer
> 
> in my case: getMemberByFieldName("ORT") should return product.ort;
> 
> Can somebody please advise me about a solution that is available?
> 
> Remark: BaseObject.getByName(java.lang.String field) does not contain any
> generic functionality at all.
> 
> Thanks in advance.
> Marc
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>