Showing posts with label NHibernate Query Analyzer. Show all posts
Showing posts with label NHibernate Query Analyzer. Show all posts

NHibernate Query Analyzer + ActiveRecord

It's been a long time since I last posted something.

My work at Chemtech is really motivating and is keeping me busy. Well, I think this is good because I really like to work and while I help my team building new projects, we as a group contribute in some way to the world.

Each day I learn new things and the tip I want to pass ahead is related to a new tool I knew a few days ago. It's called NHibernate Query Analyzer. NHQA helps a lot while working in a project with a relational database that makes use of NHibernate as the persistence manager.

I was having a problem getting NHQA to work with a business data layer constructed with the help of ActiveRecord - I searched the Internet for a path that would led me in the right direction and after solving small errors I got NHQA working with a proper configuration file. Below I post the content of the file so that you can get a sense of what must be done with the initial configuration of NHQA:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" ></section>
  </configSections>

  <activerecord>
    <config>
      <add key="hibernate.show_sql" value="true" />

      <add key="hibernate.connection.driver_class" value="NHibernate.Driver.OracleClientDriver" />

      <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />

      <add key="hibernate.dialect" value="NHibernate.Dialect.OracleDialect" />

      <add key="hibernate.connection.connection_string" value="Data Source=YOUR DATA SOURCE;User ID=YOUR USER ID;Password=YOUR PASSWORD;" />
    </config>
  </activerecord>

</configuration>

See a screenshot of NHQA with a business data layer DLL plus the app.config file:

NHQAMainForm

To get it going, just hit the Build Project button and once it’s built, just open a new Query (ctrl + Q) and start visualizing the SQL generated from the Hibernate Query Language (HQL) you type. Besides this great feature you can also view the results from an HQL query in both tabular and object graph formats.

Get a copy of the app.config file here.

Hope this helps.