Skip to main content


In order to "put my money where my mouth is" about open source ColdFusion software, today I registered a new project at called CFHibernate. If you're familiar with Hibernate for Java, what I'd like to do is give ColdFusion users the tremendous capabilities that Hibernate has to offer. If you're not sure what Hibernate is, read on ...


Hibernate is an object-relational mapping (ORM) persistence framework for Java. What this means is that you define XML mapping files that describe your objects to Hibernate, and Hibernate creates your relational database model for you as well as many of your business objects (beans). Then in your application code, you literally don't ever have to write any SQL code. That's right, no SQL code. You make calls to the Hibernate service and it handles the database interaction for you. Being able to pass objects to Hibernate and not worry about all the "junk" that we typically have to concern ourselves with when persisting objects in an RDBMS is extremely powerful and very cool stuff.

The CFHibernate project is obviously in the pre-planning stages. I've been messing with Hibernate for Java for a little over a week now is all, but I'm extremely impressed and would absolutely love to be able to use this same functionality in my CF applications. Maybe it was the tedium of writing a bunch of DAOs that brought this on. ;-) At any rate, if you're interested in this effort and want to help, please consider registering on and signing up for the project. It's a big undertaking but I think it would be a huge benefit to OO CFers, and since the Hibernate code is in Java it might even be relatively leverageable (if that's even a word).


I wouldn't say that hibernate "creates" your business objects for you... although it will instantiate them. It doesn't create your DAO's either... something has to TELL hibernate what to do, and that's usually a "DAO"-type class/cfc/whatever. I'd actually say it would more likely be called a "service", that extends hibernateDAOSupport, and thus can get() save() and find() objects of the proper type for you. The beauty of hibernate is the abstraction of the storage "medium". Is it a database? Is it xml? What if it's just an in-memory cache? Who cares! Disclaimer: everything I just said was provided w/ my "limited experience" with Hibernate.

Well, actually Hibernate does create your business objects for you if you want it to. You can create an XML mapping and Hibernate will generate all your Java code for your business objects (by "business objects" I'm talking beans here) for you, complete with getters, setters, the appopriate datatypes, etc. This is based on what I've been doing with Hibernate anyway--I didn't have to write a single Java bean by hand, I just had to write the Java classes that use the beans (the application itself, in other words). Also based on what I've been doing, it doesn't create your DAOs for you either, but then again you don't really need any DAOs. Once you set up all your mapping files those tell Hibernate what to do when you call the various methods on Hibernate and pass it the objects you want persisted in your database. To me that's one of the big advantage of Hibernate. Yes, it also abstracts the storage mechanism, and this is another huge advantage. You want to switch from MS SQL to MySQL, or to Oracle, or HSQLDB, or whatever ... all you do is change a single properties file to tell Hibernate to use a different "dialect", give it the new driver and connection info, and you're literally done. That means changing about 4 lines of code in one file and seriously, that's all there is to it. I'm admittedly pretty new to Hibernate as well, but it definitely can generate a lot of code for you if you want it to. Yes, you still have to create XML files that it can use so it knows what you're wanting to do, but that's a lot simpler than writing the objects by hand, and these mapping files are also used to generate your database schema.

ahh yes... I remember reading that it could do that (create your "beans"), but never having seen it set up that way in practice, it must have slipped my mind. I will be trying my best to contribute to the project, but as I said last night, it's quite a large undertaking.

Yep, most definitely a large undertaking, but I think it's a worthwhile one, and hey, better too much ambition than not enough. ;-) Even if this project gets part-way to the full Hibernate feature set I think we'll get some darn useful tools out of it.

Matt, This is a great idea. I don't know how much time I have to contribute but I would like keep in the loop. Can I suggest you create a RSS-capable mailing list for the project so folks can monitor via their favorite newsreader? I find google groups works fine for the CFE list (topica doesn't do RSS). -Phil p.s. Want to help me win a Mac Mini ;)

Thanks Phil--I'll check into the RSS thing. It would be cool if cfopen had this built in but I'm not sure if it does. It has mailing list functionality I see but I haven't looked any further. I'm not sure how much time I'll have to contribute myself ;-), but I'm going to do what I can because I'm really excited about the possibilities this would offer. I need to do an even deeper dive into Hibernate itself to make sure I understand it really thoroughly but even after a week of working with it I think I have a decent handle on the functionality at a high level and how it works on the surface. The hard part will be digging into the technical side of how it does what it does, where the cutoff point between what Java code can be leveraged and what can't is, etc. It's going to be interesting if nothing else! As for the Mac Mini, I'm not sure I can help since I've already registered. My wife said she'd sign up on someone's if they can get someone who isn't registered to return the favor on mine, but since we're in the same household I'm not sure that would work either. If you know how they check, etc. and what's legit and what isn't, send me an email and I'll see what I can do.

I have a base DAO that I started uses a cf structure to map tables to a bean. This could easily be changed to use XML like Hibernate does. I would be happy to share it as a part of this project if people think it would help.

Excellent--we'll take all the help we can get! Thanks Kurt!

Matt some people have got hibernate working with coldfusion over on the flex yahoo group It takes a fair amount of modification to coldfusion as the cf log4j.jar is an old version. Maybe blackstone will provide easier integration.

Thanks Mike--I found some references to that but didn't ever see the message that they got it working. I'll have to look into that because I'm curious exactly what they're doing with it, how they're persisting things, etc. My goal would be to use CFCs as my objects and be able to pass those into Hibernate, which I don't believe you can do. Now of course you could use Java objects as your beans within CF (which I've done before with Mach-II), but I really don't want to go that route because then it's a hybrid Java/CF application instead of a CF application that happens to use parts of the Java version of Hibernate or alternatively has its own CF-based ORM. Thanks a lot for the link though--I'll follow up with these folks and see exactly how they're approaching this.

Great stuff, Matt. I was just talking with Hal Helms earlier this evening about the problem of getting old RDBMS-heads (like me) to see the world in something other than a relational model. A project like this would go a long way to reinforce the "database last" attitude that we encourage in FLiP, and stress the application model instead of the storage model.

Thanks Jeff--I must admit when I first started reading about Hibernate I was a bit doubtful about how well it would handle the database schema generation piece. It's actually quite amazing--in the applications I've been playing with so far Hibernate does pretty much what I'd do myself, it sets up indexes, primary and foreign key relationships, and is pretty darn adept at handling one-to-many and many-to-many relationships. As with any of these sorts of tools you have to know a little about how it "thinks" to get the results you want, but it's amazingly straight-forward, and as you said it takes the emphasis off the database model and puts us completely in the object realm. I think (as Hal's said 100 times) that's another hangup we all have as we switch from procedural to OO; there's still that pesky database we have to deal with that doesn't quite think in objects. With ORMs you can let the computer worry about all that stuff! I'll admit that I'm probably still in the honeymood period with Hibernate, but I think I've dug semi-deep so far and I don't see any glaring annoyances yet. It does a great job of mapping objects to an RDBMS and has huge advantages when it comes to switching an application from one datastore to another as well. It's going to be challenging getting this going in ColdFusion but I think it's something that would make a lot of the repetitive stuff we all do on a daily basis a whole lot less tedious.

Don't forget the advantage of managed lazy loading. Let hibernate handle all the caching. Hibernate has a performance impact, like any other persistence layer, so use it wisely. :)

I was part of the group that is mentioned in the Yahoo group. Basically, our goal was slightly different than your stated goal here. We wanted to have all of our business logic in one place (Java), and be able to use ColdFusion (using Mach-II) for a public site, and Flex for an internal order-entry site. We were able to get Hibernate to work correctly with Flex without any real problems (other than understanding Hibernate and how it works). And I must say that we've been nothing short of amazed at how well Hibernate seems to work. However, we were unable to get ColdFusion to work correctly with Hibernate for any length of time. We ran into several issues, and most of them seemed to stem from JRun itself (mostly the classloader). We would be able to get it to work with an instance based version of CFMX, but then it wouldn't work with a standalone version of CFMX. We also ran into cross compatability issues between the Mac and PC, where something would work on the Mac, but not on PC. In looking around the internet, we were unable to find anyone else who had broached the subject of Hibernate for CF, or even JRun. Because of a project deadline, we had to essentially scrap the Hibernate for ColdFusion concept. We do plan on picking it up though in a couple months. It's a very daunting task, but I think it's possible and should definitely be explored!

Yep Micha, everything's a tradeoff and there are defintely some performance issues that you have to be aware of with Hibernate. By that I mean (based on what I've done with it so far) you just have to be very aware of how you're using it, when things get loaded, etc. etc. Luckily the Hibernate folks are well aware of what the gotchas are and it's documented quite well. I'll be curious to see how all this translates over to the CF side and I begin working on all of this.

Thanks for the follow-up Rob. Based on what I could tell from the flexcoders list I thought that's what you were doing. It's an option I considered but I'd really like to see a more CF-centric solution that wouldn't force people to use Java objects. Not that it's a bad solution necessarily, but it's one level removed from CF and would required CFers to learn enough Java to build their beans in Java. Simple enough really, but it's not CF. :-) I definitely think it's possible to get this rolling in CF, but you're right, pretty daunting. I'm just going to take it one step at a time and see how it all plays out. Thanks much for the feedback.

Good to see someone else trying this. I have NOT been able to get this working so far. I am primarily a JAVA/J2EE developer doing back end work for presentation layers done in CF. I love Hibernate for my JAVA projects and I am trying to implement it in the CF environment for my team. I'm registered at but I am unsure of how to sign up for the project development.

Excellent Troy--just e-mail me your ID and I can add you to the project.

Matt, I am running JBoss and Bluedragon. Having some trouble with the datasource configuration. Hibernate docs point you to put the config in conf/server.xml for Tomcat. BD doesnt have this file.. instead has bluedragon.xml. Do you know how to set the datasource setting for JBoss + BD? Thx Joe

I could not make work Hibernate and Flex, could someone help me?

Miguel--there was some discussion on this quite a long time ago over on the Flex Coders list at Yahoo! Groups. If you search the Yahoo! Groups you should be able to find it, then search within that group for Hibernate and there's some information available.

I am hoping to implement a ColdFusion / Java hybrid application that uses POJOs and Hibernate in

the model, and coldfusion for the view and controller.

I've been thinking about the issues with running hibernate on CF for a while and have come up with

the following idea.

Part 1
1. Download the source for the Commons Logging package
2. Create an Eclipse project for it
3. Refactor the base package for commons logging to be: instead of
4. Build a jar. cf-commons-logging.jar

Part 2
1. Download the souce for Hibernate
2. Create an Eclipse project for it
3. Refactor the base package for Hibernate to be: instead of
4. Buidl a jar. cf-hibernate.jar

Part 3
Place the 2 jars you created above, along with all other supporting jars where CF can pick them up

and start/restart ColdFusion

I forgot one of the most important steps in my post above!!!

In part 2, before you build the cf-hibernate.jar, there should be an additional step:

** Do a search and replace in the entire hibernate source and update all references to: org.apache.commons.logging
to instead point to:

Actually, now that I think about things, Step 3 under Part 2 should be eliminated. There is no need to change hibernate's package name.

So ignore the following instruction:
3.) Refactor the base package for Hibernate to be: instead of

and instead do the following:

3.) Do a search and replace in the entire hibernate source and update all references to: org.apache.commons.logging
to instead point to:

Beware. i tried to follow these steps today. i agree they seem like they should work & probably will in the end, but much labor! I followed build instructions carefully. Using Eclipse 3.1.

i tried building hibernate versions 2.1.2, 2.1.3, and 3.0CR2.
In each case the source files are missing this package

i can find nothing about this through extensive searching. building commons logging with the renamed packages went smoother.

See my post to the hibernate forum (perhaps a solution will come)

It looks like you actually have to build hibernate using the build.xml file that comes with it to generate this package. Then you'd have to do the refactoring..

See the notes at the bottom of the page:

And checkout this line in the build.xml file.



Man, I've got to spend some time and get this working. Back to work...

Here's a re-pose with the stuff that was between tags having it's tags removed so you can acutally see what I was posting.

It looks like you actually have to build hibernate using the build.xml file that comes with it to generate this package. Then you'd have to do the refactoring..

See the notes at the bottom of the page:

And checkout this line in the build.xml file.
property name="parser.src" value="${generated.src}/org/hibernate/hql/antlr"/
target name="init.antlr" depends="init"
description="Check ANTLR dependencies."
uptodate property="antlr.isUpToDate"
srcfiles dir="${grammar.dir}" includes="*.g"/

Man, I've got to spend some time and get this working. Back to work...

I got CFMX 7.0.1 and Hibernate 3.1.3 working!!!! I don't know how far other people got CF and Hibernate to work, but this is totally working!! I'm doing full CRUD functionality!!

I followed the steps I outlined in my prevoius posts, which was pretty much refactoring the commons-logging and log4j packages to be "" instead of "org.apache..." and then I updated any references in the Hibernate source code to the commons-loggging and log4j packages to now point to my new "" packages.

So after that I had 3 jar files

I then put these files in:
and restarted MX

(I also put in the MySQL connector JAR and a JAR that my application uses - my app is a cf/java hybrid)

I created a simple test CFM template which executed a number of business actions (Java Classes) which handle all my hibernate access, and detaching objects.... and I could do everything, with NO complaints from CF!!

Why to write cfhibernate you can use hibernate...

Hi Kurt,
Can you publish the modified .jar files somewhere, so anybody can use these files?



Popular posts from this blog

Installing and Configuring NextPVR as a Replacement for Windows Media Center

If you follow me on Google+ you'll know I had a recent rant about Windows Media Center, which after running fine for about a year suddenly decided as of January 29 it was done downloading the program guide and by extension was therefore done recording any TV shows.

I'll spare you more ranting and simply say that none of the suggestions I got (which I appreciate!) worked, and rather than spending more time figuring out why, I decided to try something different.

NextPVR is an awesome free (as in beer, not as in freedom unfortunately ...) PVR application for Windows that with a little bit of tweaking handily replaced Windows Media Center. It can even download guide data, which is apparently something WMC no longer feels like doing.

Background I wound up going down this road in a rather circuitous way. My initial goal for the weekend project was to get Raspbmc running on one of my Raspberry Pis. The latest version of XBMC has PVR functionality so I was anxious to try that out as a …

Running a Django Application on Windows Server 2012 with IIS

This is a first for me since under normal circumstances we run all our Django applications on Linux with Nginx, but we're in the process of developing an application for another department and due to the requirements around this project, we'll be handing the code off to them to deploy. They don't have any experience with Linux or web servers other than IIS, so I recently took up the challenge of figuring out how to run Django applications on Windows Server 2012 with IIS.

Based on the dated or complete lack of information around this I'm assuming it's not something that's very common in the wild, so I thought I'd share what I came up with in case others need to do this.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Assumptions and CaveatsThe operating system is Windows Server 2012 R2, 64-bit. If another variant of the operating system is being used, these instructions may not work properly.All of the soft…

Fixing DPI Scaling Issues in Skype for Business on Windows 10

My setup for my day job these days is a Surface Pro 4 and either an LG 34UC87M-B or a Dell P2715Q monitor, depending on where I'm working. This is a fantastic setup, but some applications have trouble dealing with the high pixel density and don't scale appropriately.
One case in point is Skype for Business. For some reason it scales correctly as I move between the Surface screen and the external monitor when I use the Dell, but on the LG monitor Skype is either massive on the external monitor, or tiny on the Surface screen.
After a big of digging around I came across a solution that worked for me, which is to change a setting in Skype's manifest file (who knew there was one?). On my machine the file is here: C:\Program Files\Microsoft Office\Office16\LYNC.EXE.MANIFEST
And the setting in question is this:
Which I changed to this: <dpiAware>False/PM</dpiAware>
Note that you'll probably have to edit the file as administr…