db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Monroe" <Greg.Mon...@DukeCE.com>
Subject RE: Get type of fields in auto generated classse
Date Thu, 17 Jan 2008 23:30:03 GMT
All record objects and table Peer objects will have a
getTableMap() function.  You can use this to access all
the schema information.  E.g.:

rec.getTableMap().getColumn(fieldName).getType();

Will return a "sample object" of the same type as the
field.  Note that the XML can defined the objects being
returned via the getFieldName() methods as primitives.  
Since you can't return a primitive, the getType() 
returns the Object version of the primitive.  You may
need to check the usePrimitive property to verify the
actual type.

> -----Original Message-----
> From: Martin Tilsted [mailto:tiller@daimi.au.dk] 
> Sent: Thursday, January 17, 2008 5:27 PM
> To: torque-user@db.apache.org
> Subject: Get type of fields in auto generated classse
> 
> Is there a way to make a method, that given a field name, and 
> any auto generated object, can return the type of that field?
> 
> Something like
> boolean isFieldAnInteger(BaseObject obj,String fieldName)  {
>     // What here. (And is BaseObject the correct class to 
> use, if you want to accept something that can be any torque 
> auto generated class?) }
> 
> At first I thought I could do
> Class c=obj. getByName(field).getClass(); But that don't work 
> if obj is a newly created object, becasue getByName will return null.
> 
> Martin
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.

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


Mime
View raw message