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
5
votes
1 answer

NHibernate CreateAlias - Joins on arbitrary columns

This question seems to come up a bit and I've yet to see a good answer. I have two classes with no foreign key and no real relationship other than a common field, in this case "Title". This is loosely based on an example I'd recently pulled from a…
5
votes
2 answers

Trouble using nHibernate 2.0's Session.Get on a class with a composite-id

I'm having trouble with something that (I think) should be simple, but can't find any clear info. In the scenario where I have three tables, describing a domain where a person can have more than one job: Person - has PersonId, Name Job - has…
joshua.ewer
  • 3,944
  • 3
  • 25
  • 35
5
votes
1 answer

Fluent NHibernate mapping IDictionary in a smart way

Given these classes: using System.Collections.Generic; namespace FluentMappingsQuestion { public class Entity { public virtual int Id { get; set; } public virtual IDictionary Properties { get; set; } …
Marcin Seredynski
  • 7,057
  • 3
  • 22
  • 29
5
votes
2 answers

Mapping one-to-one relationship with a wrong (brownfield) database schema

I have to model this relationship in NHibernate (simplified the code a bit to stay on-topic) - an employee can be an accountmanager (so, it's optional): table Employee (Id, Number, Name) table EmployeeIsAccountManager (Number,…
TedOnTheNet
  • 1,082
  • 1
  • 8
  • 23
5
votes
1 answer

FluentNHibernate mapping of one column to two properties: is this possible?

The legacy database I work with has a table with some sample information shown below: LiabilityType 134 137 140 143 146 999 001 003 006 009 These codes actually contain two bits of information: Whether the debt is classified as an expense or…
David
  • 15,750
  • 22
  • 90
  • 150
5
votes
5 answers

NHibernate with string primary key and relationships

I've have just been stumped with this problem for an hour and I annoyingly found the problem eventually. THE CIRCUMSTANCES I have a table which users a string as a primary key, this table has various many to one and many to many relationships all…
John_
  • 2,931
  • 3
  • 32
  • 49
5
votes
2 answers

How to Map a VIEW without unique identifing column with Fluent Nhibernate

i have readonly VIEWs in an existing Database and i'd like to get them with FHN. i tried mapping it the following way: public class HhstMap : ClassMap { public HhstMap() { Table("HHST"); ReadOnly(); Id(); …
blindmeis
  • 22,175
  • 7
  • 55
  • 74
5
votes
1 answer

How to auto generate IDs in NHibernate

How can I make NHibernate autogenerate unique IDs for a table? The IDs can be any long values, as long as each one is only used once. My current mapping looks like this: This creates…
Toast
  • 596
  • 2
  • 19
  • 39
5
votes
2 answers

NHibernate Many-to-many

I have a legacy database and I am trying to create a NHibernate DAL. I have a problem with a mapping on Many-To-Many table. The Database tables: studio_Subscribers studio_Groups (contains a IList of Subscribers) studio_Subscribers_Groups -…
jmw
  • 2,864
  • 5
  • 27
  • 32
5
votes
1 answer

NHibernate mapping one table on two classes with where selection

We would like to map a single table on two classes with NHibernate. The mapping has to be dynamically depending on the value of a column. Here's a simple example to make it a bit clearer: We have a table called Person with the columns id, Name and…
Rene Schulte
  • 2,962
  • 1
  • 19
  • 26
5
votes
2 answers

Nhibernate: building a List through

If I have a field in the db which stores a set of comma separated strings (says tags), how can I instruct fluent Nhibernate to pick it up at List() e.g. Public IList Tags {get; set;} Db field values: Mvc, .net, FNH
Quintin Par
  • 15,862
  • 27
  • 93
  • 146
5
votes
3 answers

How to fine tune FluentNHibernate's auto mapper?

Okay, so yesterday I managed to get the latest trunk builds of NHibernate and FluentNHibernate to work with my latest little project. (I'm working on a bug tracking application.) I created a nice data access layer using the Repository pattern. I…
Venemo
  • 18,515
  • 13
  • 84
  • 125
5
votes
1 answer

Fluent NHibernate: mapping complex many-to-many (with additional columns) and setting fetch

I need a Fluent NHibernate mapping that will fulfill the following (if nothing else, I'll also take the appropriate NHibernate XML mapping and reverse engineer it). DETAILS I have a many-to-many relationship between two entities: Parent and Child.…
moribvndvs
  • 42,191
  • 11
  • 135
  • 149
5
votes
2 answers

Types from multiple assemblies and namespaces in nhibernate mapping files

You can specify the namespace and assembly to use types from at the top of HBM files: Can you use types from multiple…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
5
votes
1 answer

Exclude property from INSERT command in nhibernate

I have an entity with a property which I wish to be readonly - meaning that when I insert this entity to the DB, SqlServer will generate the property's value automatically so I need nhibernate to ignore this property when executing the INSERT…
RiskX
  • 561
  • 6
  • 20