You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Marc Lustig <ma...@marclustig.com> on 2003/01/14 14:20:20 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

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

Posted by Marc Lustig <ma...@marclustig.com>.
Thanks, that's good to know.
But I think this would be a useful function.
My first idea was simply de-capitalize the FIELD obtained from the Peer and
then use introspection to get the corresponding field or get-method from the
BO.
But as you mentioned, the database column name and the BO-member name might
not correspond directly.
So I'm afraid this demands a solution on a more lower level. Best would be
if torque adds additional methods at the time of BO creation.

Actually, perhaps just adding generic functionality to
BaseObject.getByName(java.lang.String field) would do the job.

Marc




> -----Ursprungliche Nachricht-----
> Von: Gareth Boden [mailto:gareth.boden@egsgroup.com]
> Gesendet: Dienstag, 14. Januar 2003 14:26
> An: Turbine Torque Developers List
> Betreff: Re: how to map Peer.field-name --> BO-member
>
>
> I don't think it's possible. The Peer fields are the database column
> names, and the BO methods might have different names, and there doesn't
> seem to be a map of this information available at runtime.
>
> G.
>
> On Tuesday, January 14, 2003, at 01:20  pm, 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>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


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

Posted by Gareth Boden <ga...@egsgroup.com>.
I don't think it's possible. The Peer fields are the database column 
names, and the BO methods might have different names, and there doesn't 
seem to be a map of this information available at runtime.

G.

On Tuesday, January 14, 2003, at 01:20  pm, 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>
>