Questions tagged [nhibernate-mapping]

XML mappings for the .NET framework object-relational mapper (ORM) NHibernate as created with .hbm.xml files.

NHibernate mappings done in XML files indicate how classes map to database objects. Refer to the relevant NHibernate reference section for details on how to create such mappings.

2300 questions
8
votes
1 answer

NHibernate: Why would you use over to map a collection

When using NHibernate, under what circumstances would you choose to map a collection using a composite-element to give a collection of value objects, rather than creating a full-blown entity and mapping it using one-to-many? You might have a…
Matthew Winder
  • 502
  • 7
  • 11
8
votes
1 answer

How do I use Fluent NHibernate to map a self-referencing folder hierarchy?

I have a folder hierarchy represented by the following class: public class Folder { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Folder ParentFolder { get; set; } public virtual…
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
8
votes
3 answers

How do I map a property with no setter and no backing property fluently with NHibernate?

Let's say I have the following entity: public class CalculationInfo { public virtual Int64 Id { get; set; } public virtual decimal Amount { get; set; } public virtual decimal SomeVariable { get; set; } public virtual decimal…
Brandon Linton
  • 4,373
  • 5
  • 42
  • 63
8
votes
2 answers

Minimal and correct way to map one-to-many with NHibernate

I am new to NHibernate and C#, so please be gentle! I have the following two NHibernate entities: Employee { private long _id; private String _name; private String _empNumber; private IList
_addresses; …
markvgti
  • 4,321
  • 7
  • 40
  • 62
8
votes
2 answers

Strategies for Mapping Views in NHibernate

It seems that NHibernate needs to have an id tag specified as part of the mapping. This presents a problem for views as most of the time (in my experience) a view will not have an Id. I have mapped views before in nhibernate, but they way I did it…
Nathan Fisher
  • 7,961
  • 3
  • 47
  • 68
8
votes
6 answers

NHibernate mapping attributes vs fluent NHibernate

Do mapping attributes offer the same versatility as nhib hbm's do? Can you use them together with FNH to handle things FNH doesn't yet do as well as hbm's can? Cheers, Berryl By mapping attributes, I don't mean hbm files; there are apparently…
Berryl
  • 12,471
  • 22
  • 98
  • 182
8
votes
2 answers

HasOne vs References Mapping Fluent NHibernate

This is the first time I am working with FluentNhibernate Mapping and facing a question of how to reference another table. Any help is appreciated: I have several tables named CD_varname and all these contain two columns - CODE and DESCR. I have one…
Aparna
  • 81
  • 1
  • 1
  • 3
8
votes
3 answers

NHibernate custom collection type

I'm having an entity object called Patient and this entity is having a property called Visits which is of type VisitsCollection. VisitsCollections is a child class of IList but it also adds some custom logic to the collection (like auto…
8
votes
4 answers

Modeling one to zero or one relationships (Z cardinality)

I'm struggling to find the best way to model 1 : 0,1 relationships ("may have one" or "has at most one"). I believe this is called Z cardinality. For example, suppose I have two classes Widget and WidgetTest. Not all Widgets are tested and the test…
Jamie Ide
  • 48,427
  • 16
  • 81
  • 117
8
votes
2 answers

What is the correct way to define many-to-many relationships in NHibernate to allow deletes but avoiding duplicate records

I've been fighting with an NHibernate set-up for a few days now and just can't figure out the correct way to set out my mapping so it works like I'd expect it to. There's a bit of code to go through before I get to the problems, so apologies in…
Kevin Wilson
  • 7,753
  • 8
  • 35
  • 39
8
votes
3 answers

How to map a set of enum type in Hibernate?

In hibernate, is it possible to define a mapping for a class to a set of enums? I've been able to find examples of how to define mappings of Sets and I've been able to find separate examples for how to map Enums, but I cannot figure out how to…
Cuga
  • 17,668
  • 31
  • 111
  • 166
8
votes
6 answers

MySQL & NHibernate. How fix the error: Column 'ReservedWord' does not belong to table ReservedWords?

"I am getting a weird error when using NHibernate. And I don't know what is causing this error. I am new to the whole Visual Studio and NHibernate, but not to Hibernate. I used Hibernate in the past in Java projects. Any help would be appreciated in…
Eduardo Xavier
  • 1,520
  • 21
  • 29
7
votes
3 answers

NHibernate is producing SQL with a bad join

I have an NHibernate Linq query which isn't working how I would expect. The problem seems to come from using a nullable int column from a left joined table in the where clause. This is causing the join to act like an inner join. var list =…
7
votes
3 answers

FluentNHibernate or port to NHibernate mapping by code

I have several projects using NH and FNH to generate the mappings (some Fluent some Automapped). There are still some bugs and missing features i need, but it seems that FNH could die because of mapping-by-code integrated into NHibernate. Question:…
7
votes
1 answer

NHibernate Error Message: Invalid index 3 for this SqlParameterCollection with Count=3

I have a test database design like this: The following is the pseudo-code: //BhillHeader public class BillHeader { public BillHeader() { BillDetails = new List(); } public virtual int BillNo { get; set; } …
Nagesh
  • 1,288
  • 3
  • 22
  • 46