yaormaAdmin said:
Thanks for the feedback. The special bit in the code shown on the
front page is in the Database.getData(sqlString, conn) call.
Basically it encapsulates the boilerplate code that opens the cursor
on the database side (e.g by creating a Statement and a ResultSet).
Often in large projects someone, somewhere, inevitably forgets to
Fire that person. There's nothing "inevitable" about such a rookie
mistake.
Reply: I often work with people who do make these types of mistakes
and often in a collaborative environment where I'm not able to make
the call to fire the person. Also, we often need to continue to
invest in the person we have even after they make mistakes rather than
start all over in the process of bringing someone up to speed on our
specific domain as well as up to speed on basic Java and basic coding
principles and best practices. The Yaorma code shown on the home
pages aims to eliminate this one specific type of error that is
particularly difficult to track down because it often does appear as
and effect at a distance error.
close the Statement and/or the Resultset in a finally block where an
<
http://download.oracle.com/javase/6/docs/api/java/sql/
Statement.html#...()>
"Note: When a Statement object is closed, its current ResultSet
object, if one
exists, is also closed."
Reply: Fair enough.
exception is thrown. This results in a cursor being left open in the
database. Eventually the code is executed enough times to exhaust the
maximum number of cursors allowed for the connection. The next call
that opens a cursor in the database fails. This is often not the
offending code but some perfectly good code that exists in some other
far off place in the code.
How "often" does that happen? What statistical basis do you have for
such a
claim? Where is your evidence?
Reply: Yup, this is based entirely upon my experience. I have seen
this type of error often (at least half a dozen times in the past few
years) in my own personal experience. I don't have the resources to
conduct a formal study to find out exactly how often this occurs. If
you've never seen this type of problem come up in a large scale
database project I'd consider you lucky or privileged to work with
nothing but very disciplined knowledgeable coders in a very robust
processes or both.
Since yaorma encapsulates all of this boilerplate code (i.e. the
allocation and deallocation of the Statement and Resultset objects and
the opening and closing of the database cursors) this type of error is
prevented. Also, its easier to get the data in the single
Database.getData(sqlString, conn) call than to write the boilerplate
And what if you aren't ready to deallocate the Statement?
Reply: The code on the homepage address a very simple example. For
process that require a more complex use of the data an alternative
(slightly, but only by a little) method is provided by the framework.
Basically it is an ioc pattern that has the client code call the
framework to get the data and then process the data through an
implementation of an interface.
code to create the statement, create the result set, iterate through
the result set, marshal the data into some type of data object, close
the result set in a finally block, close the statement in a finally
block, etc.
You make it sound much harder than it really is. Remember, closing
the
'Staztement' also closes the 'ResultSet'? Of course, being a helpful
API
write, surely you knew that already. If you didn't, how could we
trust your
API given that level of ignorance?
Reply: Source code is available for review from source forge.
Marshaling the data is not boilerplate. It depends on the particular
data to
marshal, i.e., the structures of the tables and entities. Iteration
is all of
one expressions, rs.next(), in a loop condition.
Reply: Marshaling data isn't always boilerplate but often can be. In
the simple case shown on the homepage the data are simply marshaled
into an array of hashes. Each row in the array is a hash. The key to
each hash is the name of the column in the database table converted to
a standard Java naming convention (_s are removed and camel case is
applied so message_table becomes messageTable). This is similar to
what is often done in languages such as Perl. Using this methodology
assumes a reasonably small data set will be returned from the database
(i.e. all of the data are marshaled before moving on to any processing
of the data). Examples for handling large data sets is also given as
an example on the web site (not trying to drive traffic to the site
here, I just need to get back to my day job).
The 'try' ... 'finally' is embedded into the subconscious of every
competent
Java programmer. Taking away control of that from the programmer is
not
usually a good thing.
Reply: fair enough.
The pages in the more details link (
http://www.yaormama.orÄ/pages/
details.html) at the bottom of the homepage go into some of this stuff
as well as some of the other functionality including parametrized
queries, the generation and use of data value objects, marshaling data
from web pages, and marshaling data from the database in constant
space (e.g. for large data sets) etc.
How well does this sliced-bread thingie work with JPA?
Reply:
It is much simpler than JPA.
--
Lew
Ceci n'est pas une fenêtre.
..___________.
|###] | [###|
|##/ | *\##|
|#/ * | \#|
|#----|----#|
|| | * ||
|o * | o|
|_____|_____|
|===========|