Dear Stephen,
Thanks for your tips regarding the accessing of table and field
names. You suggestions were helpful and almost works in my case.
> {Use] ..Intake.. [for populating your objects].
Thanks. I hadn't seen that. Exactly how 'fragile' is it?
> You can get field names by doing:
> Torque.getDatabaseMap().getTable(XxxPeer.TABLE_NAME);
<snip/>
> ..if you just have Xxx, you can do Xxx.getPeer().TABLE_NAME.
I just have Xxx, which in my case, is of type BaseObject.
Unfortunately, BaseObject doesn't define a stub for getPeer, so
my code won't even complile. Note that I use BaseObject
because I need my code to be generic and can't be coding for
a particular database table.
Failing some other better idea, could we add a 'not-implemented
exception throwing' stub for getPeer to BaseObject.java?
[I can't help feeling that I'm going run into other problems
caused by BaseObject not defining a 'non-implemented' stub for
the methods that are generated in the XxxBase objects. ]
> As far as the toXml method, I'd rather not see the code go into
> Torque, especially the generation templates, as Torque is complex
> enough as it is.
Your choice. I'll work up a separate class, most likely using
some of your and the others suggestions (BeanUtils, Castor, etc.)
That aside, and having looked at the code, I am pleasently surprised
to see how simple it really is. This is not to take anything away
from Torque, just merely to say that the code seems reasonably
well organized and easy to read.
BEst wishes,
Alan.
P.S. The entire diff to implement the table name method and the
field name list is only:
Object.vm:
851c851
< public synchronized List getFieldNames()
---
> public static synchronized List getFieldNames()
1492,1501d1491
< }
<
< /**
< * Get the database table name associate with this
< * class: E.g.: $table.Name
< * @return the database table name.
< */
< public String getTableName()
< {
< return "$table.Name";
BaseObject.java
61d60
< import java.util.List;
339,385d336
< }
<
< /**
< * Retrieves a list of the field names from the object.
< * Must be overridden if called.
< * BaseObject's implementation will throw an Error.
< *
< * @return list of field names.
< *
< */
< public synchronized List getFieldNames() {
< throw new Error("BaseObject.getFieldNames: " +
NOT_IMPLEMENTED);
< }
<
< /**
< * Retrieves the object's database table.
< * Must be overridden if called.
< * BaseObject's implementation will throw an Error.
< *
< * @return list of field names.
< *
< */
< public String getTableName()
< { // We'd like this to be static, but then it cannot be
overridden.
< throw new Error("BaseObject.getTableName: " +
NOT_IMPLEMENTED);
< }
--end--
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>