Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
breglerj
Product and Topic Expert
Product and Topic Expert
1,179

What is NHibernate?


NHibernate is an object-relational mapping (ORM) framework for the Microsoft .NET platform. It is a port of the popular Java framework Hibernate. The framework can be used to map .NET objects from an object-oriented domain model to relational database tables. The framework's feature set also comprises query and retrieval capabilities which automatically translate between object-oriented .NET code and relational SQL queries.

What's new?


Until now there was no support for SAP HANA included in the NHibernate framework. Starting with release 5.2 there are now NHibernate dialects for the SAP HANA column and row stores as well as an NHibernate driver abstraction for the SAP HANA data provider for Microsoft .NET available.The dialects implement the full range of functions provided by SAP HANA including database-generated identity columns, sequences, table and column comments, and more.

How can I get started?


Get SAP HANA, express edition


If you want to try out Hibernate on SAP HANA you can get a free version of SAP HANA, Express Edition.

There are several options to run HANA:

Download the SAP HANA clients


The SAP HANA clients including the SAP HANA data provider for Microsoft .NET are available at https://tools.hana.ondemand.com/#hanatools.

Simply download and install the client package for your platform on your local machine. For more information on installing the clients you can follow the instructions from the SAP HANA Client Installation and Update Guide.

Configure your project


A tutorial on how to get started with NHibernate is available on the NHibernate web site. The tutorial is written using Microsoft SQL Server as its database. For the tutorial to work on SAP HANA there are two changes necessary: the NHibernate configuration file must be adapted and the SAP HANA data provider for Microsoft .NET must be added to the project instead of the Microsoft SQL Server data provider.

NHibernate configuration for SAP HANA


Here is a sample configuration for SAP HANA
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.HanaColumnStoreDialect</property>
<property name="connection.driver_class">NHibernate.Driver.HanaDriver</property>
<property name="connection.connection_string">Server=hxehost:39015;UserID=nhibernate;Password=nhibernate</property>

<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>


Make sure to adjust the connection string (host, port, user name, password) to match your database information.

SAP HANA Data Provider for Microsoft .NET


The SAP HANA Data Provider for Microsoft .NET (Sap.Data.Hana.v4.5.dll), which is installed as part of the SAP HANA client installation, is (unless specified otherwise during the installation) located at C:\Program Files\SAP\hdbclient\ado.net\v4.5\.

If Visual Studio was installed before the SAP HANA clients were installed, you can add the SAP HANA Data Provider for Microsoft .NET via the Visual Studio Reference Manager. Right-click on your project's "References" folder and choose "Add Reference...". Search for "hana" and choose the assembly named "Sap.Data.Hana for .NET 4.5".






Happy coding!
2 Comments