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
81
votes
3 answers

Referencing 2 different versions of log4net in the same solution

I'm using NHibernate 2.1.2.400 that is referencing log4net 1.2.10.0. In the same project, I also use the simply accounting SDK, sadly it is still using log4net 1.2.9.0. So I can get NHibernate to work if I reference log4net 1.2.10.0 but the…
Joel Gauvreau
  • 3,586
  • 4
  • 29
  • 32
80
votes
6 answers

How to delete child object in NHibernate?

I have a parent object which has a one to many relationship with an IList of child objects. What is the best way to delete the child objects? I am not deleting the parent. My parent object contains an IList of child objects. Here is the mapping for…
Mark Struzinski
  • 32,945
  • 35
  • 107
  • 137
74
votes
1 answer

Fetch vs FetchMany in NHibernate Linq provider

NHibernate eager loading can be done using Fetch and FetchMany, as described in NHibernate Linq Eager Fetching on Mike Hadlow's blog. What is the difference between these two methods and under what circumstance would each be used?
Simon
  • 1,499
  • 3
  • 17
  • 23
74
votes
12 answers

Best way to save a ordered List to the Database while keeping the ordering

I was wondering if anyone has a good solution to a problem I've encountered numerous times during the last years. I have a shopping cart and my customer explicitly requests that it's order is significant. So I need to persist the order to the…
Tigraine
  • 23,358
  • 11
  • 65
  • 110
70
votes
3 answers

When to use inverse=false on NHibernate / Hibernate OneToMany relationships?

I have been trying to get to grips with Hibernate's inverse attribute, and it seems to be just one of those things that is conceptually difficult. The gist that I get is that when you have a parent entity (e.g. Parent) that has a collection of…
James Allen
  • 6,406
  • 8
  • 50
  • 83
65
votes
3 answers

Which .NET data type is best for mapping the NUMBER Oracle data type in NHibernate?

I've seen some examples in which decimal is used in NHibernate projects for mapping to whole number columns in Oracle. Right now I'm using int and long in my program. What are the advantages of decimal over int/long? Does it perform better?
Ilya Kogan
  • 21,995
  • 15
  • 85
  • 141
62
votes
1 answer

SaveOrUpdate Vs Update and Save in NHibernate

What is the difference between SaveOrUpdate and Save/Update in NHibernate. Why wouldnt you just always use SaveOrUpdate? Also, what is the point of SaveOrUpdateCopy?
RD3
62
votes
4 answers

How can I have NHibernate only generate the SQL without executing it?

I know how to log the SQL to log4net/NLog/trace window at runtime with the show_sql configuration option. What I'm looking for is a way to give a Query() to NHibernate retrieve the generated SQL. I've looked through the Persister class, the…
hometoast
  • 11,522
  • 5
  • 41
  • 58
61
votes
12 answers

What is the best way to improve performance of NHibernate?

I have an application that uses NHibernate as its ORM and sometimes it experiences performance issues due to how the data is being accessed by it. What kind of things can be done to improve the performance of NHibernate? (Please limit to one…
Ray
  • 187,153
  • 97
  • 222
  • 204
54
votes
3 answers

NHibernate using QueryOver with WHERE IN

I would create a QueryOver like this SELECT * FROM Table WHERE Field IN (1,2,3,4,5) I've tried with Contains method but I've encountered the Exception "System.Exception: Unrecognised method call: System.String:Boolean…
Faber
  • 2,194
  • 2
  • 27
  • 36
54
votes
1 answer

How to update database table schemas with NHibernate schema generation?

I'm trying to figure out how to use NHibernate configuration with mapping to update table schemas, rather than dropping and recreating them. Currently I'm using the NHibernate.Tool.hbm2ddl.SchemaExport obj with FluentNHibernate to generate the…
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138
53
votes
7 answers

Disable NHibernate logging

I have an empty app.config file, but I still get NHibernate debug logs NHibernate: SELECT this_.LogID as LogID71_0_, this_.Level as Level71_0_, this_.Message as Message71_0_, this_.EventTime as EventTime71_0_, this_.Component as ... I tried adding…
ripper234
  • 222,824
  • 274
  • 634
  • 905
52
votes
5 answers

What is a Projection?

What is a Projection, in terms of database theory and NHibernate when using SetProjection()?
DaveDev
  • 41,155
  • 72
  • 223
  • 385
52
votes
5 answers

How to persist an enum using NHibernate

Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum. I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum)…
Meidan Alon
  • 3,074
  • 7
  • 45
  • 63
52
votes
3 answers

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console?

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console? I'm using MsSqlConfiguration.MsSql2008.ShowSql() but it has no parameters and I can't find anything on Google.
Andre Pena
  • 56,650
  • 48
  • 196
  • 243