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
6
votes
2 answers

Mapping custom enum classes with Fluent Nhibernate

Reading some posts from Jimmy Boggard and wondering - how exactly is it possible to map those beasts with fluent nhibernate? How mapping would look like for this? public class EmployeeType : Enumeration{ public static readonly EmployeeType …
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
6
votes
1 answer

Nhibernate - Mapping List doesn't update List indexes

I'm having one self-referencing class. A child has a reference to its parent and a parent has a list of children. Since the list of children is ordered, I'm trying to map the relation using NHibernate's . This is my mapping:
Thomas Lundström
  • 1,589
  • 1
  • 13
  • 18
6
votes
1 answer

NHibernate ConventionModelMapper; What is the difference between IsRootEntity & IsEntity

I'm playing around with Sharp Architecture Lite, which emphasizes convention over configuration, and trying to understand how the NHibernate ConventionModelMapper works. Specifically, I can't tell the difference between the IsRootEntity & IsEntity…
6
votes
1 answer

How can I map to a joined subclass with a different column than the id of parent?

I am working with a brownfield database and am trying to configure a subclass map which joins to its subclasses with a column other than that of the specified id. The login table has a primary key column login_sk which I'd like to use as its id. It…
6
votes
3 answers

What is hibernate and n-hibernate?

What is hibernate and n-hibernate? can I use it in Visual Studio 2008 for C# Web Application development ? Pls Suggest me... I am newer to asp.net web application Developement. Just I heard about Hibernate.. How can i learn and implement in easy…
6
votes
1 answer

Duplicates when eager fetching a reference (many-to-one)

First of all, yes, I am using DistinctRootEntityResultTransformer. I have the following (Fluent NHibernate) mapping: public FirstObjectMap() { Id(x => x.Id): HasMany(x => x.SecondItems).KeyColumn("FirstObject_ID"); } public…
5
votes
1 answer

Querying unmapped properties in nhibernate

I am working with Linq-To-NHibernate. I need to use some properties that is not mapped to columns. For example Repository .Find() .Select(p => new PersonModel() { Id = p.Id, FullName= p.FullName,Position = p.Position }); The position…
user39880
5
votes
3 answers

NHibernate - how to delete an item from many-to-many relationship?

I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'ProjectUser' in my case? public ProjectMap() { Id(x => x.Id); Map(x => x.ProjectName); …
5
votes
3 answers

How to make Nhibernate generate table with Text field instead of nvarchar(255)

I'm trying to make NHibernate generate my schema/SQL 2008, and using the mapping below it keeps wanting to create an nvarchar(255) column instead of text...any ideas?
Webjedi
  • 4,677
  • 7
  • 42
  • 59
5
votes
2 answers

nHibernate 3.2 database config in code?

NHibernate seems to have some new ways to map entities in code, which is really nice, but I can't find any information about configuring the database connections in code. It has been a while since I used NHibernate (version 2) and I am used to…
A.R.
  • 15,405
  • 19
  • 77
  • 123
5
votes
2 answers

NHibernate - multiple JOIN to the same table by different keys

Another NHibernate JOIN problem. I'm trying to join two different properties from one table by different two keys. But I can't get the second JOIN property. Simplified example - My class - namespace Domain { public class Message { …
Mr Mush
  • 1,538
  • 3
  • 25
  • 38
5
votes
1 answer

NHibernate Mapping Null Object / Special Case Pattern

I'd like to have an 'UnassignedDepartment' object instead of letting employees have a null Department: public class UnassignedDepartment : Department { public UnassignedDepartment() : base("not yet assigned") { Id = -99; <-- just some Id…
Berryl
  • 12,471
  • 22
  • 98
  • 182
5
votes
2 answers

How to add Filter definitions with Nhibernate 3.2 mapping by code?

The ModelInspector doesn't seem to provide the means to define Filter definitions . Any ideas/Workarounds? I need to generate the following with mappings by code:
Newbie
  • 7,031
  • 9
  • 60
  • 85
5
votes
3 answers

How to ignore mapping of property using mapping by code "Conventions"

Is there any way to avoid a property from being mapped with NHibernate 3.2 using mapping by code conventions? By default, all properties are mapped.
Newbie
  • 7,031
  • 9
  • 60
  • 85
5
votes
1 answer

NHibernate Table Per Class loading - wrong type

I have a mapping issue with the table-per-class hierarchy in Fluent/NHibernate. When retrieving the records from the database, I keep getting an error (the Wrong type exception) Object with id: 2445763 was not of the specified subclass: ClassA…