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
1
vote
1 answer

how can I make nhibernate cascade save a set of objects with circular references?

I am assuming nhibernate can handle circular reference issues as I have not seen this mentioned otherwise in the docs or on google (but perhaps I have the wrong terms). Suppose I have a class which has as a member a reference to an instance of…
fostandy
  • 4,282
  • 4
  • 37
  • 41
1
vote
1 answer

NHibernate many-to-one relationship

We have the following Domain objects :- public class UserDevice : BaseObject { // different properties to hold data } public class DeviceRecipient:BaseObject { public virtual UserDevice LastAttemptedDevice{get;set;} } Hence the sql schema created…
1
vote
2 answers

NHibernate + default getdate() column

How do I configure NHibernate to create the db schema with a column like this: create_dt datetime not null default getdate() I have this in the mapping file:
dotjoe
  • 26,242
  • 5
  • 63
  • 77
1
vote
2 answers

Fluent nHibernate Getting HasMany Items In Single Query

I have a Topic map which has many posts in it i.e… (At the bottom HasMany(x => x.Posts)) public TopicMap() { Cache.ReadWrite().IncludeAll(); Id(x => x.Id); Map(x => x.Name); *lots of other normal maps* References(x =>…
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
1
vote
1 answer

Fluent nHibernate configuration for custom type

I'm trying to get fNH to map to a custom type, but I'm having difficulties. I want fNH to assign its value, via an interface to the custom type. I also need nHibernate to preserve the instance of the custom type on the entity. It will always be…
1
vote
1 answer

NHibernate mapping by code Map collection

I'm moving from xml mapping to a code based mapping. There is a problem I'm experiencing with NHibernate Map collection. Below is the xml mapping which perfectly works (it is a bit simplified, there is actually more properties and…
Alex M
  • 2,410
  • 1
  • 24
  • 37
1
vote
1 answer

define NHibernate mappings in different assembly than the domain objects

I have an assembly Foo.Bar that holds all my domain logic and my domain object (e.g. public class Project, public interface IProjectRepository). I also have an assembly Foo.Bar.Data that acts as my NHinbernate data access layer wich holds the…
bitbonk
  • 48,890
  • 37
  • 186
  • 278
1
vote
1 answer

How to convert Fluent NHibernate mapping to NHibernate Built-in Code Based Mapping

I have two classes from example using Fluent NHibernate mapping. Fluent NHibernate mapping is commented and I´m trying to make Code Based Mapping, but still appears ArgumentNullException "Value cannot be null.". How to make it right? //Fluent…
Czechtim
  • 51
  • 8
1
vote
2 answers

help needed on Nhibernate mapping (Parent/Child relationship)

I am new to Nhibernate and I am using Nhibernate 2.1.0 RC1. In C# I have the following classes: public class Application { public virtual int Id { get; set; } public virtual Applicant Applicant { get; set; } } public class Applicant { …
Jeff
  • 13,079
  • 23
  • 71
  • 102
1
vote
1 answer

NHibernate Mapping: Simple Join on a Foreign Key

The Tables Currencies ---------- CurrencyId INT IDENTITY PK IsoCode4217 CHAR(3) -- "USD", "GBP", "EUR", etc Users ---------- UserId INT IDENTITY PK CurrencyId FK REFERENCES Currencies (CurrencyId) The Mapping The current application has a…
Nicholas Piasecki
  • 25,203
  • 5
  • 80
  • 91
1
vote
1 answer

NHibernate - Mapping custom reference types in legacy system

I am working on legacy system,and I'm in the process of porting it to nhibernate. The system is based on generated "Entity" C# classes, and a data access infrastructure which is based on wrapping cross-entity references in a special "Link" class.…
tal952
  • 953
  • 12
  • 18
1
vote
2 answers

NHibernate, saving IDictionary : TransientObjectException

In my class Case I have an IDictionary with Entity (a class) as key and Roles (an enum) as value. When trying to save a new instance (non-persisted) of Case, where the IDictionary is filled with new instances of Entity I get the following…
user135609
1
vote
4 answers

Many-to-Many fluent NHibernate mapping with SQL Azure

Since SQL Azure requires clustered indexes for every table for replication (see here http://blogs.msdn.com/b/sqlazure/archive/2010/05/12/10011257.aspx) I have added the following MsSqlAzureDialect to my MsSqlConfiguration: public class…
1
vote
2 answers

How to use generated Guid primary key as foreign key while inserting into child table in NHibernate 3.2?

I am trying to persist an object into the database. This operation should touch two tables. [HttpPost] public ActionResult Create(Report report) { try { report.Positions = new Iesi.Collections.Generic.HashedSet(); …
mrt181
  • 5,080
  • 8
  • 66
  • 86
1
vote
2 answers

Mapping two columns with the same name in nhibernate

I've come across a case, we're I've a column mapped twice (un-beknown to us..), and now updates are throwing the "Parameter +1 doesn't exist error". Is there any suitable way we can achieve the following mapping? (Please note, this is an inherited…