Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate Query Analyzer

Could anyone please describe how to use NHibernate Query Analyzer? I downloaded it and trying to build it but it fails, I am not quite sure how to use it.

I am using nHibernate with Sybase and WCF.

Any help is greatly appreciated.

Thanks

like image 567
VoodooChild Avatar asked Oct 26 '22 14:10

VoodooChild


1 Answers

Setup NHibernate Query Analyzer (NHQA) Project

After downloading the tool, run Ayende.NHibernateQueryAnalyzer.exe and then:

File -> New -> Project

Click 'Add File(s)...' button and add the following files:

  1. your NHibernate configuration file (i.e. *.cfg.xml, *.exe.config, or *.web.config file)
  2. your assembly DLL (or DLLs) that contain the NHibernate mapped classes and also have the mapping file(s) as an embedded resource
  3. your mapping files only if they have not been added as embedded resources to the DLLs in # 2

(note: in older versions of NHQA, it was necessary to copy the DLLs including its dependencies to the same directory as the NHibernateQueryAnalyzer.exe but that is no longer the case)

Click 'Build Project' button

If receive errors, then something needs to be fixed in either the configuration file, the mapping file(s), the classes in the DLL(s), or all of them. It is important to note the exception messages to help troubleshoot and identify which of the above is source of the problem.

Run Queries

After successfully building the NHQA project, you can create queries:

File -> New -> Query

Now, type in HQL statements. Entities' names and properties can be dragged and dropped from the tree view on the left to your HQL statements on the right. As you type, it provides on-the-fly checking and validation of your HQL statements in the 'Exceptions' tab and displays the auto generated SQL statements in the 'SQL' tab. A sidebar GUI is also available for dynamically defining named parameters.

Hit F5 to execute the query. If it executes successfully, you can view the results in tabular form in the 'DataBase Results' tab or as objects in the 'Object Graph' tab.

Configure Files

New Mapping files can be created by:

New -> Mapping (hbm.xml)

or existing ones can be edited directly:

Open -> Open Mapping...

Same for Configuration files:

New -> Configuration (cfg.xml)

Open -> Open Configuration...

References

Documentation on setup and usage tutorial for NHibernate Query Analyzer is quite sparse but hopefully the above helps.

like image 174
Ray Avatar answered Nov 04 '22 19:11

Ray