FusionReactor's JDBC Driver Wrapper is a great addition to ColdFusion 9's Object-Relational Modeling capabilities. You can use it to spy on what Hibernate (ColdFusion's ORM provider) is really doing to your database.
This article doesn't go into detail about what ORM is, or how it works – there are many posts and articles on the web which cover this in detail:
Adobe's integration of the third-party Hibernate framework brings ORM functionality to your CFC-based applications. This brings with it some new, important concerns for ColdFusion developers:
- How is Hibernate converting my entity operations to SQL?
- Why are they running so slowly?
- How is Hibernate locking the DB?
You can use the setting Application.cfc setting this.ormsettings.logSQL to have Hibernate dump its SQL to the log as it's created, but you'll soon find the log is overflowing with data.
- FusionReactor's JDBC Driver Wrapper associates your queries with the precise request – and ultimately CFC/CFM line of code – in which they run.
- You can use the JDBC tab in FusionReactor's Request View to see what ran, how long it took, and how many rows came back – great for tuning and catching runaway queries.
Getting this working is simple, just follow the steps below.
- Download and install FusionReactor – you'll need version 3.5.0 or better. You can get a 10-day free trial here.
- You'll need to create a wrapped datasource. This won't replace your original datasource, but it will allow our lightweight wrapper to spy on he interaction between ColdFusion, Hibernate and the database.
- You can use the instructions in the FusionReactor JDBC Driver Wrapper User Guide, or download and use our free tool (just run the tool and have it wrap your datasource automatically).
- Once you've got a wrapped datasource, change your ORM datasource in Application.cfc to point to the new datasource.
.. for example.
Once you've installed the FusionReactor JDBC Driver Wrapper, and adjusted your Application.cfc to point to the wrapped datasource, you can have a look at the collected data. We ran the 01_createmusician.cfm script from Mark Mandel's introductory app (from Introducing ORM in Adobe ColdFusion 9), with this.ormsettings.logSQL = true turned on in our Application.cfc.
What came out in the log was:
But that's not only what ran – the log isn't showing you everything. Inspecting the JDBC tab of the request in FusionReactor actually shows us exactly what's going on:
There's actually a whole bunch of overhead. We turned on "Record In Order" in FusionReactor's JDBC Settings, so this list is in time order – including a whole set of alters, drops, creates (JDBC transaction 1), then the load of sample data (transactions 2 and 3), the actual insert from the CFM page itself (transactions 4 and 5), and the select from the page for the dump (transaction 6).
We think FusionReactor's JDBC Driver Wrapper is an awesome tool to spy on exactly how Hibernate and ColdFusion 9 is interacting with your database. Object-Relational Modeling is going to revolutionize how you deal with your databases, and FusionReactor is going to make your life easier in analyzing and solving problems.
|Last Updated:||08/Sep/11 10:50 AM|
|Fixed Version:||3.5, 4.0.0|