Click here to Skip to main content
15,898,991 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 Updated

NHibernate 

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.
8 Jan 2017 by #realJSOP
Your application is throwing an exception that you aren't handling. Period.My bet is that it's a file system problem, but a guess is the best any of us can provide. Put a try/catch block around your main form's initialization code that displays an error message in the catch part, and I bet...
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?
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...
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")] ...
30 Dec 2013 by Aarti Meswania
because it missing alias for sub querywrite as belowvar Query = session.CreateSQLQuery(string.Format(SELECT * FROM(SELECT * FROM Users WHERE UserCode ='admin' AND PASSWORD = '123' UNION SELECT * FROM Users WHERE UserId IN (SELECT UserRoleId FROM UserRole WHERE UserId = (SELECT UserId...
15 Mar 2014 by Abhinav S
TryHow to do Inner Join in NHibernate[^]NHibernate - Critieria Query Joins[^]
20 Dec 2021 by Adam Flow
A short look into the possibilities of AutoMapper's operation options
1 Jan 2022 by Adam Flow
As stated in this wiki: Fluent NHibernate Any Quote: There are three things you need to provide to be able to map using an Any; a column that holds the type of the entitiy, at least one column holding the identifier value, and a type for the...
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...
23 Jan 2015 by agould1
So I've looked around quite a bit for assistance to this problem as the error seems somewhat common, but I've exhausted all my options. I've tried several implementations as suggested but I just can't get past it. Here's the exact error:"Foreign key (FK6482F24702A58C9:Category [fkCategory,...
23 Jan 2015 by agould1
Turns out there was another attempt at this same problem in the solution but the map was wrong. Once I commented out this map (as it's essentially a dead map now) everything workedusing FluentNHibernate.Mapping;using SkillsMatrix.Domain;namespace SkillsMatrix.Mapping{ public...
17 May 2015 by Akhil Mittal
http://nhibernate.info/doc/ind...
31 Aug 2015 by Alexander Siniouguine
Entity Framework is very mature framework and will be your best bet. We use it for very large projects and it works just fine. If your application is simple and you want complete control of what happens, then you can use DataReader for the most optimal performance. Stored procedures are anti...
27 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.
21 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.
23 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.
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.
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.
21 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, and lazy initializations/fetches using NHibernate.
22 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.
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.
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.
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...
6 Oct 2011 by André Kraak
I found this Getting Row Count in NHibernate[^], see if it delivers the performance your want.
23 May 2018 by Andy_Bell
I have problem to get record form my Oracle v 11.g Server DB. It seems NHibernate and Fluent are not correctly access to Server. I try to fetch only first record in a query, I use FirstOrDefault instruction, but it converts in this Sql clausole: "FETCH FIRST 1 ROWS ONLY". This is compatible only...
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
24 Sep 2014 by Anjum.Rizwi
I also have similar problem, I am very much new to this hibernate & fluent hibernate.My table schema is like belowCREATE TABLE [dbo].[MyChildImmunisations]( [Child_id] [int] NOT NULL, [Schedule_id] [int] NOT NULL, [Status] [int] NOT NULL, CONSTRAINT [PK_MyChildImmunisations]...
13 Oct 2014 by anup ladda
I would like to know what are the approaches possible to fetch data from SQL server to MVC 5 application. I am using MVC 5 with Nhibernate.Which is better approach, in term of performance.1. ORM ( Nhibernate )2. ORM with Stored Procedure3. any other approachNote - ORM mapping is...
10 Aug 2011 by Artem Smirnov
Integration vs unit tests
23 Apr 2019 by Avneel93
I am trying to map ApplicationRequest class to Request class. One Request can have multiple ApplicationRequests, but one ApplicationRequest belongs to one Request only. Below are my classes and the relevant xml mappings. class Request { public virtual string Id { get; set; } ...
24 May 2013 by Backward91
I need to set more than one discriminate values for parent class. Is it possible to do and how?For example:PARENT_CLASSDiscriminateSubClassesOnColumn("COLUMN_NAME", "X");CHILD_CLASS_1DiscriminatorValue("Y");CHILD_CLASS_2DiscriminatorValue("Z");This is possible. But...
5 Aug 2012 by begeeben
This example demonstrates how to work on mappings with associations for legacy database tables designed purely using multiple primary keys/composite keys.
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...
31 Oct 2013 by Bhuvanesh Mohankumar
Try this site.Regex Tester[^]Your regular expression:^(\s*,?\s*[0-9a-za-z]([-.\w]*[0-9a-za-z])*@([0-9a-za-z][-\w]*[0-9a-za-z]\.)+[a-za-z]{2,9})+\s*$Your test string:bhuvan2001@gmail.comIf the Entered mail ID or contect is not matching then shows ["No Match Found"], so...
17 May 2015 by Bitto kumar
Hi All,Can anyone send me the nhibernate reference links or pdf.Thank you,
8 Oct 2015 by Bitto kumar
Hi Everyone,I am new to Nhibernate. i want to pass a parameter to .hbm file without using createcriteria() method here is my hbm file.
16 Dec 2015 by Brady Kelly
Can anyone suggest a good NHibernate tutorial for me? I have searched the CP articles for those in the last year, with ratings 3-5, and found nothing looking like what I want. I have found one good looking article, NHibernate Made Simple[^], but it's from 2007, and I suspect NHibernate has...
28 Jun 2011 by CDP1802
Why don't you just consult the Hibernate/NHibernate documentation?[^]
10 Dec 2015 by CHAITANYA KIRAN KASANI
NonUniqueObjectException was caught 'a different object with the same identifier value was already associated with the session: 64, of entity' at SaveOrUpdate method NHibernate Exception C#Savint Two Objects in Single Method Using SaveOrUpdate() method Showing the above exceptionmy...
25 Jul 2012 by Chaturvedi Dewashish
Hi,I have a block of 50k data. I use NHibernate to retrieve all (retrieving all is necessary). But as having large dataset which is created by joining 5-7 tables NHibernate takes around one minute.The main cause of slow fetching might be joining of tables for which NHibernate creates...
21 Dec 2015 by CHill60
I always find it a good idea to take information straight from the horse's mouth - i.e. use the tutorial at the NHibernate[^] site and then refer to the various How-to articles on the same link.Just because the article you found is out of date does not necessarily mean it is of no use to you...
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
14 Sep 2021 by Codes DeCodes
I want to use Fluent Nhibernate ORM in my C# project that needs to connect to Oracle and SQL Server database. I know that I need to create mapping file to map my C# objects to database objects but what I am uncertain is - Is mapping syntax going...
1 Apr 2017 by Daniele Fontani, keggyy
In this article, we explain how to build a simple and easy to use log platform, keeping in mind performance ad security.
6 May 2014 by deelll
Goal:Retrieve data into a class with support of stored procedure with nhibernate. You use nhibernate to retrieve the data by using stored procedure.Problem:I have followed some instructions (the link to the website is below) but it doesn't work because I retrieve a error message that...
28 May 2014 by deelll
If you want to retrieve some value from a database you always has to use a class that shall contain a lot of data.In my case, I want to retrieve one value only from a stored procedure and do I really need to use a class that shall contain a single value only?How should I create inside of...
2 Aug 2014 by deelll
Goal:Update the current and existing data of the row in the table kund based on new data. The new data is located in the class ContactInfo.Problem:I retrieve an error message saying "No persister for: data_layer.ContactInfo". I tried locating the root problem but I failed. I don't know...
27 Dec 2014 by deelll
If I want to retrieve a list of data and display it by using EF code first (http://msdn.microsoft.com/en-in/data/dn468673[^]) or stored procedure (http://msdn.microsoft.com/en-us/data/jj592907.aspx[^]), which of them has the shortest time to retrieve it?
11 Jul 2013 by demius
Unfortunately, you have very little control over the SQL being generated by the ORM (in this case, NHibernate). There's no easy way to improve performance, but a good place to start would be to run query analyzer and see what NHibernate is doing when you query it for data under different...
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...
1 Mar 2013 by DinoRondelly
http://stackoverflow.com/questions/267085/converting-sql-to-hql
10 Jul 2012 by dotnetter123
Hello,I have the following piece of codevar result = session.Query() .GroupBy(x => x.Name) .Select(s => new { sal = s.Sum(x =>x.Salary) ...
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...
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...
2 Jun 2011 by Dr. Song Li
I searched over .... I see many advantages, but it seems that all the advantages comes from a comparison over in-line SQL. I know in-line SQL is bad. But why compare with a bad one to show the other better?If stored procedures are used (possibly exclusively), it seems none of the advantages...
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.
18 Jul 2017 by eddieangel
I need a bit of help here trying to solve a problem using Castle Windsor and NHibernate. I have been reading different articles on this subject for a couple of days and I can't find a solution for my particular issue. What I want to do is have two database connections, a local and a remote....
7 Jul 2014 by Eduardo Antonio Cecilio Fernandes
Learn how to configure NHibernate on your ASP.NET application
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; } ...
20 Jul 2011 by Elk Cloner
28 May 2013 by Enrique Albert
Patterns and best practices for the desing and development of rich client enterprise applications using WPF, WCF and 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
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.
21 Aug 2015 by F-ES Sitecore
Please do your own basic research before asking a questionhttp://lmgtfy.com/?q=nhibernate+create+table[^]
12 Apr 2012 by Felice Pollano
There are scenarios in which NHibernate performance decreases even if we do all the effort to correctly use it.
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.
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).
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 =...
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...
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?
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.
13 Aug 2015 by Gaurav Aroraa
NHibernate threw an error when used Reserved SQLserver kerywords with in mappings, queries, etc.
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 Apr 2019 by Gerry Schmitz
Try this: Request request = session.Get("R00877"); List requests = request.Select( r => r.Requests ).ToList();
28 May 2014 by gggustafson
See How to: Create and Execute an SQL Statement that Returns a Single Value[^] for information on how to execute an SQL statement that returns a single value.
26 Aug 2017 by Gorkhali
I am trying to use nHibernate with SQL Server 2012 in my project. I am getting above said error" No persister for CafePOS.CafeTableGroup".My app.config file : ...
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?
10 Jun 2014 by gt.guybrush
Searching on StackOverflow and google i find many and many different implementation but none of that really convinced me, each had some small defect that prevented me from using it. So I tried to create my own version and would like to know what you think.Essentially everything is based on...
19 Jun 2014 by gunaaa
Please convert sql query into nhibernate query. My query is given below.SQL Query:SELECT tbl_other_related_family.record_id ,tbl_other_related_family.related_record_idFROM tbl_recordINNER JOIN tbl_other_related_family ON tbl_other_related_family.record_id =...
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...
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.
27 Oct 2015 by Ibrahim Tayseer
Hello every body, I need your help to let me know how to fix this two problems1- What should I do If I have a stored procedure which return different table structure with different columns name and column count How can I map these results in one entity ? Can I use the DataSet or the...
20 Aug 2018 by Jahongir Sabirov
I have several tables. I 'm using nhibernate in my desktop project. But when I try to save some data into my any of table through nhibernate it gives me following error {"An association from the table p_returnitem refers to an unmapped class: SmartWarehouse.Order"} My Preturnitementity is...
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...
31 May 2013 by Jignesh Khant
System.Data.DataSet ds = new System.Data.DataSet(); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("Select * from demo", "Data Source=184.107.55.15;Initial Catalog=demo;User ID=sa;Password=1947"); da.Fill(ds); // Write to XML...
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"); ...
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 =...
23 Apr 2014 by jothycse
Hi,I am new to fluent nhibernate. Please help me out to write the following sql query in fluent nhibernate.select * from user u inner join userinfo ui on ui.userid=u.userid where username="xyz".Thanks in Advance.
30 Dec 2014 by Khudha Bakhsh Mari
Hi friendsi have 3 database with same schema, i want to first database product table data and insert this table data in to remaining database product tables mean databases are individual but schema is same (may be database on individual machines but schema is same), and i am using following...
18 Jun 2014 by krish.krish
how to use nhibernate in domain driven design(ddd) application,i have smartCA project in that i have to implement nhibernate.i think the nhibernate is use in infrasture.repository section
10 Jul 2011 by Kumar, Ravikant
ABCs of NHibernate, a small application to demonstrate save and load of objects to and from Database.
18 Sep 2013 by KumarJalli
Hi,i want sample code to map the stored procedure return columns with the entity propertiessuppose i have an entity class Public Class Employeepublic Property EmployeeId as Integerpublic Property EmployeeName as stringpublic Property Salary as doubleEnd Classand...
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?