Click here to Skip to main content
15,887,821 members
Everything / NHibernate

NHibernate

NHibernate

Great Reads

by Fred Song (Melbourne)
In this article, I want to show how to build a Single Page Application – MasterChef with ASP.NET Core MVC, Fluent Hibernate, and Angular JS.
by Anand Lakshminarasimhan
A full series of 8 part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, Using Collections With NHibernate, Inheritance Relationships Using NHibernate, Lazy Initializations/Fetches Using NHibernate.
by Enrique Albert
Azure WebSite and W8 Store App using SQL-CE, Azure SQL, Mobile Services, SignalR, EF, WebAPI and integration to Bing Maps
by Gaurav Aroraa
In this step-by-step article, we will discuss all about CRUD (Create Read Update Delete) operations with Web API using Repository pattern.

Latest Articles

by Adam Flow
A short look into the possibilities of AutoMapper's operation options
by Fred Song (Melbourne)
In this article, I want to show how to build a Single Page Application – MasterChef with ASP.NET Core MVC, Fluent Hibernate, and Angular JS.
by Member 13652889
Setup nhibernate and fluent mapping for an ASP.NET project
by Swinkaran
This practice demonstrates the basics of NHibernate and shows how to integrate NHibernate into .Net & MVC environment with an example CRUD application

All Articles

Sort by Score

NHibernate 

6 Feb 2020 by Fred Song (Melbourne)
In this article, I want to show how to build a Single Page Application – MasterChef with ASP.NET Core MVC, Fluent Hibernate, and Angular JS.
23 Nov 2012 by Anand Lakshminarasimhan
A full series of 8 part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, Using Collections With NHibernate, Inheritance Relationships Using NHibernate, Lazy Initializations/Fetches Using NHibernate.
24 Jun 2013 by Enrique Albert
Azure WebSite and W8 Store App using SQL-CE, Azure SQL, Mobile Services, SignalR, EF, WebAPI and integration to Bing Maps
16 Oct 2014 by Gaurav Aroraa
In this step-by-step article, we will discuss all about CRUD (Create Read Update Delete) operations with Web API using Repository pattern.
15 May 2013 by Anand Lakshminarasimhan
A full series of 8 part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, Using Collections With NHibernate, Inheritance Relationships Using NHibernate, Lazy Initializations/Fetches Using NHibernate.
3 Oct 2016 by Fred Song (Melbourne)
In this article I talk about how to use ASP.NET Core MVC, Fluent NHibernate and Angular JS to implement a CRUD SPA (Single Page Application).
22 May 2013 by Anand Lakshminarasimhan
A full series of eight part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, using collections with NHibernate, Inheritance Relationships using NHibernate, Lazy Initializations/Fetches using NHibernate.
20 Jan 2013 by Anand Lakshminarasimhan
A full series of 8 part articles to show One-To-One, Many-To-One, Many-To-Many associations mapping using NHibernate, Using Collections With NHibernate, Inheritance Relationships Using NHibernate, Lazy Initializations/Fetches Using NHibernate.
27 Jan 2012 by Samer Aburabie
Fluent NHibernate Automapping for Unidirectional ManyToMany relationship
14 Jan 2012 by Henry He
In this article, I will explain what transparent lazy loading is and how it's implemented in NHibernate and Entity Framework.
25 Feb 2015 by Sacha Barber
Triggers/Rowcount And NHibernate
1 Jan 2022 by Member 9614352
I am new to Nhibernate and I don't know how to create a polymorphic relationship/mappings in my application. I have tried different solutions and tutorials but unfortunately I am still not been able to figure out how can I make this work. Following is my database structure in which...
13 Nov 2012 by Dylan Morley
You need a reference to Iesi.Collectionshttps://nuget.org/packages/Iesi.Collections[^]It wants version 1.0.1, which you can get herehttps://nuget.org/packages/Iesi.Collections/1.0.1[^]Use package manager to install the reference.
5 Jun 2011 by Sander Rossel
I have been using the Entity Framework for a while now. A few advantages for me are automatic Class creation from the DB metadata and using LINQ. Also, using an ORM tool does not mean you cannot use Stored Procedures. I do not think one method is better than the other. It depends on requirements...
5 Jun 2011 by #realJSOP
One advantage is that you learn how to not expect a 3rd-party library to be a magic bullet, and that no matter what you select, there will be issues to overcome.
21 Jul 2011 by RaisKazi
Have a look at below link for NHibernate dynamic connection string change.Dynamic NHibernate Connection String
24 Oct 2011 by RaisKazi
You will have to convert your Image into byte[].Have a look at below link for Mapping and Entity settings/types.http://stackoverflow.com/questions/337789/how-to-map-image-type-in-nhibernate
26 Jan 2012 by Wonde Tadesse
Not quite sure what exactly your problem is. Perhaps this Phil Haack article might help you greatly.Using jQuery Grid With ASP.NET MVC[^]
26 Mar 2012 by Mario Majčica
Try with this methodpublic static DataTable ToDataTable(this IList data) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T)); DataTable table = new DataTable(); foreach (PropertyDescriptor prop in...
8 Nov 2012 by Nemonics
I am trying to implement NHibernate 3.2.2 updating application coded originally written with NHibernate 1.2.1. Needless to say, I have needed to make a number of changes just to successful ly compile the code. I am now stuck with the following exception that occurs when I attempt to read any...
16 Feb 2013 by Sandeep Mewara
Following CP article will explain you on how to integrate NHibernate with ASP.NET: NHibernate Best Practices with ASP.NET, 1.2nd Ed.[^]Download the sample, go through article, learn and try out!
15 Mar 2014 by Abhinav S
TryHow to do Inner Join in NHibernate[^]NHibernate - Critieria Query Joins[^]
17 Dec 2014 by George Jonsson
You can use XmlDocument[^].XmlDocument xmlDoc = new XmlDocument();XmlElement elRoot = xmlDoc.CreateElement("body");xmlDoc.AppendChild(elRoot);XmlElement elParam = xmlDoc.CreateElement("param");XmlText elValue =...
23 Jan 2015 by Wendelius
Based on the error message you getForeign key (FK6482F24702A58C9:Category [fkCategory, pkCategory])) must have same number of columns as the referenced primary key (Skill [pkSkill])The definition for the foreign key isn't as you described. Instead you have 2 columns in the foreign key...
31 Oct 2016 by Richard Deeming
The SqlFunctions will only work with LINQ to SQL; the EntityFunctions can only be invoked from Entity Framework.If you want to call a specific function from NHibernate, then you'll need to create a custom dialect:Pure Dot Net Coder: Using DateAdd with NHibernate Linq[^]Alternatively,...
28 Jun 2011 by vamsimohan21
I am new to NHibernate. Is it possible to create a criteria for the below scenariopublic class A{public string name {get; set;}}public class B { public string name {get; set;}}public class C { public string firstname {get; set;} public string lastname {get;...
8 Jul 2011 by Vijayeb
I am Using a Iset Collection in my code.This gives me an error like this operation not supported in wcf.I am using wcf test client inorder to test my methods.I am Using Nhibernate in my application to map.User.hbm.xml
20 Jul 2011 by Elk Cloner
9 Aug 2011 by Christophe_
I am trying to use NHibernate on a legacy database that manages some sort of generic tables. I'll explain below.I have a "base" table with 3 fields (I removed unrelevant fields) : Base ( Address (int, Primary key) ClassId (int) Identifier (string) ...
12 Aug 2011 by Christophe_
I eventually found a way to map this legacy model using foreign-key="none" on many-to-one property and adding a unique-key on ClassId and Identifier fields
28 Aug 2011 by tamash_ionut
Hello everyone,I have the following code:public class Hotel{ public int ID { get;set } public IList Photos { get;set; }//...other code}and public class Photo{ public int ID { get;set }//...other...
29 Aug 2011 by Ganesan Senthilvel
Yes, itz possible. I'm not much familiar with NHibernate; but with the related ORMs like LInQ, etc. The customized mapping is achievable by writing our own Convert methods aspublic void List ConvertEntityHotelToPhoto(Hotel hotel){ List retPhoto = new List(); foreach(Photo photo...
6 Oct 2011 by Mikey M.
Okay,I have the following scenario. I have a Firm that can have 0 to x Users. I have a Firm entity and a User entity.I hand-rolled my own repository layer using ADO.NET, and now I'm switching that over to NHibernate, but I'm stuck on one property of my Firm entity.It's a property...
6 Oct 2011 by André Kraak
I found this Getting Row Count in NHibernate[^], see if it delivers the performance your want.
7 Oct 2011 by Mikey M.
I found what I needed here:http://stackoverflow.com/questions/2300762/how-to-map-count-of-collection-to-entity-with-fluent-nhibernate[^]I wanted this information to be declared in the mapping, and I'm using FluentNHibernate.It revolves around using something called .FormulaIs() (which...
24 Oct 2011 by nguyenle.it
Hello everyone!!I got an issue about image in NHibernate. So my problem is how can we save and load image from database in NHibernate? Could anyone can help me, please?Thanks all your comment
27 Oct 2011 by nguyenle.it
I got one, thanks all your commenthttp://nhibernate.hibernatingrhinos.com/29/lazy-loading-blobs-and-the-like-in-nhibernate
2 Nov 2011 by tgarijo
HiI have a store procedure with joincreate procedure 'getData'()beginselect tableA.id, tableA.name, tableB.description from tableAjoin tableB on tableB.id = tableA.id where tableA.id like"%";endare there program that will tell me, how to make the hbm file and class files...
2 Nov 2011 by R. Giskard Reventlov
Maybe this[^]?
25 Nov 2011 by elad2109
So far I used this code to configure a session factory: Configuration configuration = new Configuration(); configuration.Configure(); SessionFactory = configuration.BuildSessionFactory();Now I added some fluentNhibernate mapping classes, and used this...
25 Nov 2011 by elad2109
I have this class: public class AttachmentLocation { #region properties public virtual Guid UserId { get; set; } public virtual Guid LocationId { get; set; } public virtual long IndexInLocation { get; set; } ...
8 Dec 2011 by anilhash
HiIs Nhibernate will give 100% performance in 200 users where every user will transact at least 5000 records into database ? Or It will better to go your own architecture like beerhouse project in C#Any information you could give us would be appreciatedThanksAnil
8 Dec 2011 by Derek Henderson
I have had some good performance out of NHibernate (with MS SQL Server), but it really depends on what your trying to achieve. If your creating an system which needs rapid scaling, with a large number of transactions it may be worth looking into something like MS SQL Service broker (I assume...
21 Feb 2012 by andriyenglishchan
Hi! I'm a new in nHibernate help me to save an object and his connections in the base.I've got the base with two tables: 1)person (idPerson, firstName, secondName, idService 2)service (idService, name)The table service has 3 positions (gold, silver, brilliant)I use the next method for...
24 Feb 2012 by jim lahey
Hello everyone,I'm seeing some strange behaviour in NHibernate, in particular that ISession.Refresh doesn't always do what it says on the tin when I call it. My code:public TEntity Refresh(TEntity entity){ Contract.Requires(entity != null, "entity"); ...
26 Feb 2012 by Rohitash Kumar
I want to add a new column to the database table in the production hours using NHibernate without affecting the old data in the table. All the previous rows will have NULL for this column.
12 Mar 2012 by Varinder Raii
How to write Queries for retreving, Checking Existence, and all we do in SQL using NHIBERNATE (FLUENTNHIBERNATE)Is FluentNhibernate is used in these Queries.And Which one is better Fluent Nhibernate Mapping or XML MappingIs there any relation or should i know LINQ for learning...
13 Mar 2012 by qasimidl
I am using Nhibernate with asp.neti have got data using HQL in Ilistbut when i bind Ilist with gridview I gives me error "customername" field not foung in selected datasiurcealthoug i define column in gridview and there is a column with same nameMy confusion is when i...
24 Mar 2012 by Varinder Raii
Hi guys , I am doing following .public static IList RetreiveAll() { IList Company = null; try { using (var Session = ClsNhiberateHelper.OpenSession()) { ...
24 Mar 2012 by Ganesan Senthilvel
Hibernate Query Language (HQL) is case sensitive. The entity name and propery name used in HQL must be in the same case in which they are specified in CFC. It is the common mistake while using HQL.Could you verify in your code?
25 Mar 2012 by Doyle Raymond
Hi everyone,I'm trying to get the dataTable using NHibernate cos I need to bind dataTable in reportviewer, but NHibernate always return IList and i don't know how to convert into DataTable, so if anyone knows, pls help me!! tdsReport.Purchase.Merge(purchaseDT); // ??? how to get...
29 Mar 2012 by Guy Van den Nieuwenhof
MikeyDoing a count(0) will do a full table scan on the database.It is better to use Exists, as it will stop scanning the table when it finds a first match.Your code would becomeMap(x => x.HasUsers).Formula("case when exists (select 0 from [user] where firm_id = Id) then 1 else 0...
1 Apr 2012 by Doyle Raymond
Hi everyone, I've a report and I need to group that report according to parameters that I'm gonna pass it from my code. need help for my project !for exp, [Purchase] [Supplier][Group][c1][c2][Purchase] [Supplier][Group][c1][c2]in that report, [Group] parameter...
4 Apr 2012 by Eugene Sadovoi
The simplest way to implement grouping is by using CollectionViewSource[^] class. For more info on how to group your collection please refer to GroupDescriptions[^] property. The link also has an example of how it is done.
16 Apr 2012 by qasimidl
i am working with Nhibernate,c# and asp.netIs there any way to find out the mapping file ( "hbm.xml" )exist for (" cs file " ) or notin my project there are many class (" cs file " )i need to find out of mapping file ( "hbm.xml" ) of every class (" cs file " )
19 Apr 2012 by qasimidl
i am working with UltraWebGridwhen i click on header of column for sorting its giving me error The data source 'ObjectDataSource1' does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet.here is my Source code ...
28 Apr 2012 by lizaliza
I have one to many- many to one relation between customer and order with cascage="all" on the one to many.when I update single order in the custoemr and call customer.SaveOrUpdate,for some reason it creates sql statements that update all the orders.cant it just update the single order i...
3 May 2012 by touseef4pk
Hi I want to create criteria for a query but it is not working ? The query is SELECT * FROM patientdetailinformationview where (patientid=101 and PatientCaseId=1316) or (patientid=105 and Case_type=1)Please guide in this regard. Thanks in advance
4 May 2012 by jim lahey
You need to have two separate conjunctions added to a single disjunction. Something like:var conjunction1 = Restrictions.Conjunction();conjunction1.Add(Restrictions.Eq("patientid", 101));conjunction1.Add(Restrictions.Eq("PatientCaseId", 1316));var conjunction2 =...
6 May 2012 by touseef4pk
Hi, I am trying to create Nhibernate criteria for the follwing query but not getting the right idea. Plz guide. SELECT * FROM PatientDetailInformationView where PatientId in (1114155, 1114154) and PatientCaseId in (4869, 4868) or patientid in (1114155, 1114154) and case_type =1
13 May 2012 by touseef4pk
I am trying to create Nhibernate criteria for the follwing query but not getting the right idea.SELECT PEH.ResponseStatus FROM PatientEligibilityHistory PEH WHERE PEH.PatientId = " + patientId + " AND PEH.PayorId = " + payorId + " AND PEH.DateOfService = '" + dateOfService + "' AND...
13 May 2012 by Vasim889
SELECT PEH.ResponseStatus FROM PatientEligibilityHistory PEH WHERE PEH.PatientId = " + patientId + " AND PEH.PayorId = " + payorId + " AND PEH.DateOfService = '" + dateOfService + "' AND PEH.Insured_Id = '" + insuredId + "' HAVING PEH.ResponseDateTime = select MAX(PEH.ResponseDateTime) from ...
20 Jun 2012 by XmasCobra
The application that I am working on use NHibernate And FluentNhibernate, but when it runs the Compiler does not seem to be able to find the reference to the dlls."No Source Available" is shown, with these errors:Locating source for 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\Fluently.cs'....
18 Jul 2012 by gowthammanju
My question is - I need to extend some specific nhibernate class, so that it should process some values and return connection string which i need rather than the original one.Is it possible to do?
18 Jul 2012 by R. Giskard Reventlov
Start here[^].
31 Jul 2012 by Nikhil_S
I got my solution here:Basic Handling and Tips of Database Relationships in Entity Framework[^]
1 Aug 2012 by freedeveloper
I read the another answer here and in the WEB but I can not found a definitive anwser about if it is possible to insert in batch mode with fluent nhibernate and ORACLE. I try this:private void InsertData(IEnumerable coplogDetailList) { var session =...
3 Aug 2012 by Aditya Mangipudi
Usually when you are doing such bulk transaction, it is advised to use stateless sessions. Here are two good links which might be helpful in your...
25 Sep 2012 by Showne
I am using 'Bootstrapper' class inside the Method is:private static void ConfigureNHibernate() { NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration().Configure(); cfg.Properties["connection.connection_string"] =...
25 Sep 2012 by Zoltán Zörgő
What about googling a little bit: Using NHibernate with Multiple Databases[^]
13 Nov 2012 by Pepin z Hane
Hi,I have an ORM using NHibernate, in the method Select_Players() it throws an error, that cannot find some configuration files or what: Could not load file or assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The...
13 Nov 2012 by Pepin z Hane
Hi,I have a problem with table mapping, I cannot find any error, maybe I have badly written composite-key... Table name and class name is Player_in_Tournament, there is no error...Error: Could not compile the mapping document: Player_in_Tournament.hbm.xmlWeb Form where the Exception is...
14 Nov 2012 by Pepin z Hane
Hi,I am trying to select something from DB using NHibernate, but it throws this error: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column 5Error At:IQuery query = session.CreateQuery("FROM [Player] WHERE (([Pohlavi] = 'Muž') AND ([Aktivita] = 1))...
27 Nov 2012 by Pete Sutcliffe
How to work with legacy databases in NHiberbate - Compound foreign keys
22 Dec 2012 by SmartCodeproject
i have checked NHibernate.. is any drawback using NHibernate or it is same as java Hibernate. i have worked in java Hibernate it is excellent but i fear to use NHibernate bcz of further problem.. is NHibernate just like Java Hibernate or it is not properly developed by Microsoft ??
22 Dec 2012 by Richard MacCutchan
You could go straight to the NHibernate home[^] and check the details there.
28 Dec 2012 by SmartCodeproject
if i build project using Nhibernate .net then after completing project can i switch one database server to another database server only by changing single configuration file ?if it is possible then how can i do by Nghibernae .NET.i am developing project but i want to use same project in...
28 Dec 2012 by Oleksandr Kulchytskyi
thus, based on the latest updates from U.My approach lies in next.You might to create generic repository interface and leverage it for basic CRUD operation , also you can leverage it with conjunction of UnityOfWork pattern(for example to commit all affected entities)....After that you...
8 Jan 2013 by Rupali Jadhav
Hi,I want to write one query in NHibernet. The query is as followsUpdate table1 Set Date1=(Select top 1 max(Date) from table2 where Id=", IdI don't know NHibernate so not getting how to write this query. Waiting for suggestions. Thanks.Rupali.
10 Jan 2013 by Sumit_Kumar_Sinha
http://www.dot4pro.com/nhibernate-update-query.html[^]http://nathan.whiteboard-it.com/archive/2008/07/28/nhibernate-bulk-updatesinsertsdeletes-with-named-queries.aspx[^]http://darioquintana.com.ar/blogging/2007/12/11/nhibernate-bulk-manipulation-with-sql-native/[^]http://ahmedshuhel.blogspo...
7 Feb 2013 by Limelines
Hi, I have been reviewing an application, that uses NHibernate. When I investigated the data structure of the database there were no foreign keys. If the application manages the relationships between the entities should the database (MSSQL) have foreign keys set up?
7 Feb 2013 by Bernhard Hiller
Some years ago, NHibernate had problems with foreign keys: NHibernate treated all foreigns keys as if they had referential integrity enforced and did not accept null values. I do not know if NHibernate can cope with such a situation now, since that was my first project with NHibernate, and...
16 Feb 2013 by qasimidl
how to define in byte[] in hbm.xmlI am using nhibernate in asp.neti have to save pdf file into sqlservedatabase fields type is in sqlserver = varbinary(MAX)in asp.net i can retrive in byte[]what to use in hbm.xml file in propety???thanks
1 Mar 2013 by qasimidl
I am working with nhibernateI have relation of one to manyand in class there is Ilist property in class which hold one to many relationand also many to one relation in same class as well ( relation in 1 class )I want to ask how to retrieve this " ilist "...
1 Mar 2013 by qasimidl
select i.*,s.firstname ,s.lastname from student_Inquiry iinner join studentdetails s oni.Student_InquiryDetail_sno != s.Student_InquiryDetail_snohow to convert it into HQLs.Student_InquiryDetail_sno (many to one )i.Student_InquiryDetail_sno (one to many )change it and...
1 Mar 2013 by DinoRondelly
http://stackoverflow.com/questions/267085/converting-sql-to-hql
3 Mar 2013 by qasimidl
object references an unsaved transient instance - save the transient instance before flushing or set cascade action for the property to something that would make it autosave. Type: GlobalFrameWork.com._12Solutions.Global.GlobalFramework.Admin.Entity.Student_Inquiry, Entity:...
3 Mar 2013 by qasimidl
in nhibernateits giving me this errorSqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.when i am inserting data into child table where one to many relation is available(foreign key relatoinhship)and in parent class there is one to many...
3 Mar 2013 by Matej Hlatky
I think you don't have some DateTime value set and therefore you are inserting default(DateTime) value, which is 1/1/0001. SQL Server can't insert this value.
18 Mar 2013 by Aarti Meswania
I have application in nhibernate & postgresqlmigrating from sql to postgresin postgres column type is integer but It gives error while update-insert data[Property] [Column(1, Name = "is_deleted", SqlType = "INTEGER")] public virtual bool IsDeleted { get { return...
18 Mar 2013 by _Maxxx_
Purely a guess as I don't know the technology, but have you tried setting the SQLType as bit even though the real column is int?
11 Apr 2013 by Aarti Meswania
this is my postgres table CREATE SEQUENCE student_id_seq;CREATE TABLE student( id integer NOT NULL default nextval('student_id_seq'), first_name character varying, CONSTRAINT student_pkey PRIMARY KEY (id ))WITH ( OIDS=FALSE);ALTER TABLE student OWNER TO...
11 Apr 2013 by Aarti Meswania
I have solve thishope it will useful to them who facing same problem...[Class(Table = "student")]public class Student{ private long _id; private string _studentname;[Id(Name = "Id", Column = "id", UnsavedValue="0" )] [Generator(1, Class = "sequence")] ...
23 Apr 2013 by RamanSharma
I have a discriminator column in the which i need to use for select insert and update. I need to update and select the Employee type. I have following code in the mapping xml file.
1 May 2013 by radical500
It could not compile the mapping xml documents and i dont know whythis is my cfg file ...
4 May 2013 by Member 3224122
Hi I Want modular project have model,and in create sessionfactory find calssmap or models that is in module,session factory in core project and core project not reference in module project.How solw problem?
21 May 2013 by jfabus09
So this is a most peculiar behavior that NHibernate is exhibiting for me here in my MVC application. The applications without error and the class mapping looks to be set up correctly but when I monitor connectivity and such for my database, I never even see a failed query or any query at all...
22 May 2013 by jfabus09
The answer to my issue was to check the namespace and location of the various files associated with the query. I had originally put one of the files in the wrong folder and so the namespace was mapped to that incorrect folder. I moved the file into the correct folder but never changed the...