I've been toying for a while with writing business models in Java with Hibernate providing ORM capability, and using ColdFusion as enterprise "glue" to create a service tier that deals in transfer / value objects consumed by Flex, Model-Glue apps, and, well, whatever else understands basic data structures and. Largely, my reason for using Java for the model has a lot to do with Hibernate: while Transfer and Reactor both work well, neither has the backing of Hibernate.
I also think this lets ColdFusion shine at what it's meant to do: provide a great language for "glueing" together everything from service tiers to chart generation.
With ColdFusion 8, this just got a lot easier. If you're up on using Hibernate, this is all it takes to get rolling in ColdFusion 8:
Load Hibernate with a given configuration file, add JARs contains classes and mappings, and list everything all Event instances.
--->
<cfset cfgFile = createObject("java", "java.io.File").init(expandPath("hibernate.cfg.xml")) />
<cfset hibConfig = createObject("java", "org.hibernate.cfg.Configuration").init() />
<cfset mappingFile = createObject("java", "java.io.File").init("relax-contact-manager.jar") />
<cfset hibConfig.configure(cfgFile) />
<cfset hibConfig.addJar(mappingFile) />
<cfset sessionFactory = hibConfig.buildSessionFactory() />
<cfset hibSession = sessionFactory.getCurrentSession() />
<cfset hibSession.beginTransaction() />
<cfset result = hibSession.createQuery("from Event").list() />
<cfoutput>
<cfloop array="#result#" index="i">
#i.getId()# - #i.getTitle()# - #i.getDate()#<br />
</cfloop>
</cfoutput>
<cfset hibSession.getTransaction().commit() />
<cfset sessionFactory.close() />
If you're not up to speed with Hibernate, it's not hard to learn. One thing I'll be looking at doing over the next few months is writing a framework that'll automarshall graphs of POJOs to generated transfer object CFCs (and probably generate the AS3 classes to boot!).
Comment 1 written by Big Gary on 31 May 2007, at 4:19 PM
Comment 2 written by Joe Rinehart on 31 May 2007, at 4:22 PM
Comment 3 written by Jaime Metcher on 31 May 2007, at 9:03 PM
I'm just sneaking up on doing this in CF 7. Why is this easier in CF 8? Is it just the log4j versions? Is there so much of a difference that I really should wait for CF 8?
Jaime Metcher
Comment 4 written by Sami Hoda on 1 June 2007, at 12:57 AM
Comment 5 written by Mark Mandel on 2 June 2007, at 9:15 AM
Comment 6 written by Cliff Meyers on 2 June 2007, at 11:55 AM
Comment 7 written by Kurt Wiersma on 2 June 2007, at 7:23 PM
http://tech.groups.yahoo.com/group/cfhibernate/fil...
Comment 8 written by Andrew Duckett on 5 June 2007, at 1:29 PM
You mentioned you were using Java for the model, and the reason for that was Hibernate. Have you tried using Java without an ORM? I'm curious on the success/difficulties of writing your own access layer and using Coldfusion as your display/view. If so, have you seen any added overhead with Hibernate, especially in Coldfusion applications?
I'm really interested in trying this, thanks for the post!
Andrew
Comment 9 written by Deron on 12 June 2007, at 2:14 PM
Comment 10 written by Greg Conover on 17 July 2007, at 11:55 AM
Comment 11 written by Daniel Shaw on 28 February 2008, at 10:12 AM
[Add Comment] [Subscribe to Comments]