Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
If you're anything like me, using ORM the first time around is pretty scary. I have been writing my own SQL statements for well over a decade and it goes against my controlling nature to turn all of that oh-so important work, over to the ORM black box inside ColdFusion 9. Luckily, Adobe has provided a way to let us take a peek under the covers to see exactly what SQL is getting run when we execute any ORM actions. In this video, I am going to show you how to turn on ColdFusion 9's ORM SQL logging and keep an eye on what's going on in your application.
So to turn on the SQL logging, Application.cfc file inside Chapter5, we are just going to add one attribute to the ORM settings that we have set up in the previous video. So, I am going to add logsql = "true" and that's all it takes to start taking a look at what's going on inside of the ORM functionality in ColdFusion. So, let's open up hibernate.cfm and we have the same EntityLoad statement that we also used in a previous video. If I go ahead and show the console inside CF Builder, I will be able to take a look at what's going on inside my SQL statements.
But I need to make sure that if I've just turned on SQL logging, that I reload the ORM configuration. So, let's go ahead and add that up to the top here. I will do cfset ORMReload. So, we can make sure that the ORM configuration gets reloaded and SQL logging gets turned on. So, I will save my file and preview it and in the Console here, let's go ahead and make this larger. We can see that it's using log4j, an open -source Java logging application to log all of our hibernated SQL.
So, we can see exactly what it has run on our SQL Server. Now because ColdFusion 9 uses log4j, if you know how to edit the log4j properties, you could log your SQL information on to a flat file, send it via e-mail or SMS or use any other type of logging output that log4j supports. Hopefully, you can now feel a little better about using ColdFusion 9's ORM functionality. Just remember not to leave the SQL logging enabled in a production environment, as it could have a negative impact on the performance of your application, as all of this logging happens in the background.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101535 Viewers
61 Video lessons · 88293 Viewers
71 Video lessons · 72166 Viewers
56 Video lessons · 103921 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.