>>>>> "Heiko" == Heiko Gottschling <[EMAIL PROTECTED]> writes:

  Heiko> Now, here is what I thought of, and I'd like to hear your comments on this:

  Heiko> I want to create a SessionBean, let's call it DatabaseUtil, with a method
  Heiko> like:

  Heiko>   Object getRecord(String tableName, int id)

  Heiko> this method would use the java reflection package to look up a class named
  Heiko> <tableName>Value, retrieve the names of all of its public fields, construct a
  Heiko> SELECT statement from these field names, and construct a new <tableName>Value
  Heiko> object from the returned result set.

  Heiko> This approach would save a lot of redundant coding. Can you think of any
  Heiko> potential drawbacks? What about performance overhead when using reflection?
  Heiko> (I gather J2EE uses it all the time anyway)?

Assuming a usual situation where you will access objects of any
particular class a significant number of times, then cache most of the
reflection results by class.  In particular, you could cache the
PreparedStatement and the list of Field objects.

--
===================================================================
David M. Karr     ; w:(425)487-8312     ; TCSI & Best Consulting
[EMAIL PROTECTED]    ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to