the singularity of being and nothingness
Archive for September, 2012
Some Late Night Reading
Sep 20th
I am currently reading No Name, by the excellent Wilkie Collins. If you haven’t heard of him, for shame. If you haven’t read anything of his, you are pitiable above all creatures. To relieve (if only temporarily) your miserable wretchedness, I offer to you, without any pretense of context, a brilliant extract which merely feels at the edges of the creativity of this long dead, yet terrifically talented author.
Captain Wragge, the Swindler“Swindler is nothing but a word of two syllables. S, W, I, N, D—swind; L, E, R—ler; Swindler. Definition: A moral agriculturist; a man who cultivates the field of human sympathy. I am that moral agriculturist, that cultivating man. Narrow-minded mediocrity, envious of my success in my profession, calls me a Swindler. What of that? The same low tone of mind assails men in other professions in a similar manner—calls great writers scribblers—great generals, butchers—and so on. It entirely depends on the point of view. Adopting your point, I announce myself intelligibly as a Swindler”…
“Now observe…Here am I, a needy object. Very good. Without complicating the question by asking how I come to be in that condition, I will merely inquire whether it is, or is not, the duty of a More >
Custom SQL Projections…Part Second
Sep 5th
Previously, I outlined a way in which you can pretty easily extend ColdBox’s excellent CriteriaBuilder to support Hibernate Criteria SQL projections. While this certainly worked, you may remember I complained–whined, really–about how hard-codey the solution was. That is, in order to really use the SQL projections, you more or less have to build out SQL strings manually each and every time you use it. String concatenation, ugh!
Not content to leave it alone, I continued to explore ways to make this a bit better; I think I’ve struck on a significantly better way.
On the Road to a SolutionWhat I’ve created is what I call a “Detached SQL Projection”. In essence, it leverages the DetachedCriteria which I wrote about previously. Once the DetachedCriteria is sufficiently built up, the “projection” more or less grabs the SQL that *would be* generated for the DetachedCriteria. However, instead of adding it as a subquery to the main criteria object, this faux-projection uses the pre-generated SQL and creates a real SQL projection.
Here’s some code (from my extension of the withProjections() method):
// detachedSQLProjection if( structKeyExists( arguments, "detachedSQLProjection" ) ) { var propertyTypes = []; var sqlargs = arguments.detachedSQLProjection; var metaData = orm.getSessionFactory(orm.getEntityDatasource(this.getentityName())).getClassMetaData(this.getentityName()); // get session var More >