I am evaluating Groovy and it's Sql/DataSet classes for a Java EE
application. I found that it was designed without any performance
considerations (same applies to JPA).
Yes, I saw most recent 1.6 RC2 version of Sql with cached statements,
but implementations shows clearly it was an afterthought. The Sql
class is growing (code smell), DataSet (which inherits from Sql) is
unable to take advantage of that new cache and the performance is
still not that good (for example: to reuse cache, Sql's methods have
to rebuild the query (a String) from scratch on every method call and
only after that statement can be looked up in the cache).
Ok, back to DataSet, for example: when I create:
def person = sql.dataSet('person')
and in loop issue:
then for every single iteration, the DataSet object creates
preparedStatement from scratch! It has REALLY COOL solutions for
building JDBC PreparedStatements (finally no more stupid SQL syntax
with collections of column names and question marks), but there is no
way for such a statemnt to be reused, not to mention about no way of
using addbatch() and executebatch() methods of preparedStatements.
The bad thing is that DataSet is created without extensibility in
mind, so there is no simple way to encapsulate or subclass it to add
extra/missing features (like to ask DataSet to create and setup a
statement and give it back, so I could batch/execute it by my own).
Are you guys satisfied with DataSet? For me it looks like that was
created to make a good impression on newcomers. However as far as I am
concerned, there would be no big deal refactoring it, so it could be
used in many more circumstances (like for single/batch inserts,
updates/removes). Now all I can do is to create a new "my" DataSet
class by copying the original one and reimplementing it so I could add
Another cool feature could be to add an option for using JavaBeans
(for example cool "GroovyBeans" implementation) instead of Map for
What do you think?
To unsubscribe from this list, please visit: