Questions tagged [nhibernate]

NHibernate is an open source object-relational mapper (ORM) for the .NET framework.

NHibernate is an open source object-relational mapper (ORM) for the .NET framework.

It started as a .NET port of the popular Java ORM Hibernate.

Installation

Installing NHibernate can most easily be done using its NuGet package:

Install-Package NHibernate 

Resources

17517 questions
5
votes
2 answers

How to do multiple joins with NHibernate Criteria API

I have the following data model: Page - Id // Pk - Type // int Section - Id // Pk - Page // Fk Comment - Id // Pk - Section // Fk - Date // DateTime I'm trying to query all comments that are associated with a certain Page…
5
votes
3 answers

Using NHibernate mapping by code: Cannot insert explicit value for identity column in table 'DietUser' when IDENTITY_INSERT is set to OFF

Took me a while to find an answer for this so thought I'd share the love. When using NHibernate's new mapping by code with SQL Server I'm unable to save an entity. When saving an entity a System.Data.SqlClient.SqlException is thrown with the…
5
votes
3 answers

Mapping a long text string in Oracle and NHibernate

Using NHibernate 3.1 with both SQL Server and Oracle DBs, we need to store a text string that is longer than 4000 characters. The text is actually XML, but that is not important - we just want to treat it as raw text. With SQL Server, this is easy.…
Brian Berns
  • 15,499
  • 2
  • 30
  • 40
5
votes
2 answers

How to select and consume a collection of value objects in an NHibernate QueryOver query

I have a simple model, consisting of a document that references one or more article using a reference object (this is because in the domain, we do not own the articles so we can only reference them). I'm trying to write a query that lists the…
Sandor Drieënhuizen
  • 6,310
  • 5
  • 37
  • 80
5
votes
2 answers

Nhibernate error 'Invalid column name' when column does exist

Hi I have an object called document and one called user Document public virtual string Name { get; set; } public virtual string Description { get; set; } public virtual User User { get; set; } Documentmap public DocumentMap() { …
Raif
  • 8,641
  • 13
  • 45
  • 56
5
votes
2 answers

ASP.NET MVC 3 and NHibernate Scaffolding

I found this article [http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/], which explains how to use MVC Scaffolding with one-to-many relationships in EF to create a listbox with an…
Darbio
  • 11,286
  • 12
  • 60
  • 100
5
votes
1 answer

How do you map a base class using ColdFusion ORM?

I have two components, a base Entity component: And a Client component that extends it:
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
5
votes
1 answer

How do I pass parameters to a stored procedure in NHibernate when one of the parameters is a list?

I have a stored proc mapped as follows in NHibernate: exec dbo.SelectHistoricResultItem :StartDate, :EndDate, :ListA, :ListB, :ListC The following…
Franchesca
  • 1,453
  • 17
  • 32
5
votes
1 answer

Do I really add this line for each class in my model using ninject and NHibernate?

I am using NHibernate and ninject in ASP.Net MVC, using this page as a guide. One thing I think is weird is that, in this code (half way down the page) public class RepositoryModule : NinjectModule { public override void Load() { …
leora
  • 188,729
  • 360
  • 878
  • 1,366
5
votes
3 answers

What is the difference between NHibernate and iBATIS.NET?

I am looking for some up to date information comparing NHibernate and iBATIS.NET. I found some information searching Google, but a good bit of it applies either to the Java versions of these products or is dated. Some specific things I am…
Jeremy
  • 3,484
  • 3
  • 22
  • 25
5
votes
1 answer

Set default values in nhibernate-mapping

I am trying to put a default value in a mapping. When I run it says "default" not declared. my code is Is this support for nhibernate Thank you
yohan.jayarathna
  • 3,423
  • 13
  • 56
  • 74
5
votes
3 answers

Simplest way to use NHibernate for the official "ASP.Net MVC 3 Getting Started"-Tutorial

Clarified Updated Question - Start In the official MVC 3 Getting Started-tutorial it seems to me that all we have to do to get ORM working are two steps. First adding the simple MovieDBContext-code as described at the end of part 4 .. public class…
Jennifer Owens
  • 4,044
  • 5
  • 19
  • 22
5
votes
2 answers

Why NHibernate deletes referenced objects one by one, not using foreign key?

I have simple Parent-Child relationship, Parent has many Child objects, the relation is unidirectional: public class Parent { public virtual int Id { get; protected set; } public virtual string Name { get; set; } public virtual…
NOtherDev
  • 9,542
  • 2
  • 36
  • 47
5
votes
5 answers

Unable to cast object of type 'NHibernate.Collection.Generic.PersistentGenericBag'

public List FindAll() { using (ISession NSession = SessionProvider.GetSession()) { ICriteria CriteriaQuery = NSession.CreateCriteria(typeof(Application)); return (List)…
FidEliO
  • 875
  • 3
  • 14
  • 24
5
votes
2 answers

Mapping Decorator Pattern in NHibernate

Further to this question: Composition over Inheritance - where do extra properties go? The accepted answer and similar ones answer this nicely. But to take this further, what if the Sales department and Production department wanted to record…