I've just released 1.0RC of CF Groovy, including Hibernate support. You can download it, or view the demo app. The download includes both the demo and the runtime engine.
The big new feature is Hibernate support, of course. Here are a couple snippets from the demo app. First, the entity class:
package com.barneyb import javax.persistence.* @Entity class User extends AbstractEntity { String firstName String lastName String email @Column(unique = true) String username }
Then the engine setup (in code here, ColdSpring would be better):
<cfset application.cfhibernate = createObject("component", "HibernatePlugin").init() /> <cfset application.cfhibernate.setEntityPath( getDirectoryFromPath(getCurrentTemplatePath()) & "entities" ) /> <cfset application.cfhibernate.setColdFusionDsn("cfgroovydemo") /> <cfset application.cfhibernate.setAnnotatedClasses(listToArray("com.barneyb.User")) /> <cfset application.cfgroovy = createObject("component", "cfgroovy").init() /> <cfset application.cfgroovy.addPlugin(application.cfhibernate) />
Finally, doing some persistence operations:
<cfset request.sess = application.cfhibernate.getSessionForRequest() /> <g:script> import com.barneyb.* variables.user = new User([ firstName: attributes.firstName, lastName: attributes.lastName, username: attributes.username, email: attributes.email ]) request.sess.save(variables.user) request.sess.flush() </g:script> <cfset userList = request.sess.createQuery( "from User order by lastName, firstName, username" ).list() />
As you can see, very minimal fuss to do some pretty powerful things. This only scratches the surface of what Hibernate can do; the full power of the tool is available (custom annotations, the full XML mapping capabilities, caching, etc.).
Another significant change is that all non-inline Groovy is precompiled into Java classes and loaded dynamically. This gives you compiler checks on your Groovy code and engine startup, more helpful message for code errors, and some performance improvements.
Finally, as illustrated above, the <g:setPath> tag has been superceded by an explicitly managed CF Groovy runtime. This gives you complete control over the lifecycle of the engine, which lets you target performance in production and development speed in development. You can still use <g:setPath> instead of managing the runtime yourself, but that should be considered a deprecated practice.
I've been following along. This is super cool stuff. Thanks mucho.