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

NHibernate mapping with a class hierarchy whose base class is abstract and the discriminator is not a string

Here are the domain model classes: public abstract class BaseClass { ... } public class ChildClass : BaseClass { ... } Note that the parent class is abstract and this is what gives me some difficulties when comes the time to map with fluent…
9
votes
1 answer

How to generate hbm.xml file from FluentNHibernate

I'm trying to follow this tutorial but instead of generating the expected hbm.xml files with my mappings in it generates simple .cs class for my entities like for example: public class ProductMap : ClassMap But I already defined those…
Kris van der Mast
  • 16,343
  • 8
  • 39
  • 61
9
votes
1 answer

Mapping large string with Fluent NHibernate

I'm working with an Oracle DB, and I'm trying to map this class: public class Book { public virtual int Id { get; private set; } public virtual string Author { get; set; } public virtual string Title { get; set; } public virtual…
leeran
  • 298
  • 2
  • 12
9
votes
1 answer

NHibernate - auto generate timestamp on create and update?

I am trying to map an entity in NHibernate, that should have an Updated column. This should be the DateTime when the entity was last written to the database (either created or updated). I'd like NHibernate to control the update of the column, so I…
driis
  • 161,458
  • 45
  • 265
  • 341
9
votes
4 answers

Fluent NHibernate + multiple databases

My project needs to handle three databases, that means three session factories. The thing is if i do something like this with fluent nhibernate: .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())) the factories would…
Pablote
  • 4,745
  • 9
  • 39
  • 46
9
votes
3 answers

Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

I have a table with a time column in my SQL Server 2008 database. The property of the object I'm trying to map to is a TimeSpan. How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems?
9
votes
3 answers

Mapping an immutable structure as a component in NHibernate

I'm testing out NHibernate to be the solution to my company's ORM needs. To do this, I've produced a small test model based on a school, providing some useful edge-cases for NHibernate to handle. I'm having problems finding out how to map a custom…
Paul Turner
  • 38,949
  • 15
  • 102
  • 166
9
votes
2 answers

NHibernate HiLo - new column per entity and HiLo catches

I'm currently using the hilo id generator for my classes but have just been using the minimal of settings eg ... But should I really…
Gareth
  • 2,061
  • 2
  • 17
  • 22
9
votes
1 answer

NHibernate mapping one to many not on primary key

I'm working with a legacy database, and I have the following tables: Person ExternalFile ------ ------------ Id (int, PK) Key (string) ConnectionId (int) Type (int) Name …
Johan Haest
  • 4,391
  • 28
  • 37
9
votes
2 answers

Fluent NHibernate - Unnecessary update

In a unidirectional many-to-many relationship between Registration and Item, where a Registration has an ISet ItemsPurchased and Item has no reference back to registrations (it's not a useful way to explore the object graph), when I look at…
8
votes
2 answers

Nhibernate - item gets its ParentID updated to null instead of being deleted

The business logic inside a process is: begin transaction add an item to a collection perform a find("somethingA") delete that item depending on the previous step. commit transaction Im using cascade all-delete-orphans, and the inverse=true, both…
8
votes
3 answers

Query Unmapped Columns in NHibernate

I have a class that is mapped to a table using NHibernate. The problem is that only some of the properties are mapped to columns in the table. This is fine because the only columns we use for display are mapped, however I was wondering if there is…
lomaxx
  • 113,627
  • 57
  • 144
  • 179
8
votes
2 answers

Pass type to generic method (nested generic)

How can I invoke following method while I have not TRootEntity, but have just its TYPE: public void Class(Action> customizeAction) where TRootEntity : class; final goal is to run following code var mapper = new…
Afshar Mohebi
  • 10,479
  • 17
  • 82
  • 126
8
votes
4 answers

How to add mappings by namespace in Fluent NHibernate

In my application, I need to talk to multiple databases. I am handling this in NHibernate by creating one SessionFactory per database (I assume this is the correct thing to do). So I have two sets of models (one per database), and two sets of Fluent…
8
votes
4 answers

Fluent NHibernate question

Let's say you have two tables, "Users" and "UserRoles". Here's how the two tables are structured (table - columns): Users - UserID (int) UserRoles - UserID (int), Role (string) What I want is for my "User" class in my domain to have an IList of…
Kevin Pang
  • 41,172
  • 38
  • 121
  • 173