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
3 answers

How to set entire mapping to read only in NHibernate 3.2 mapping-by-code?

I'm just getting up to speed with NHibernate 3.2 and its "mapping by code" feature, and migrating our Fluent mapping over to it. Is there an equivalent of the fluent "ReadOnly();" function, to make the entire mapping read only? Thanks in advance.
Andrew Stephens
  • 9,413
  • 6
  • 76
  • 152
5
votes
2 answers

How to do multiple joins with NHibernate Criteria API

I have the following data model: Page - Id // Pk - Type // int Section - Id // Pk - Page // Fk Comment - Id // Pk - Section // Fk - Date // DateTime I'm trying to query all comments that are associated with a certain Page…
5
votes
3 answers

Using NHibernate mapping by code: Cannot insert explicit value for identity column in table 'DietUser' when IDENTITY_INSERT is set to OFF

Took me a while to find an answer for this so thought I'd share the love. When using NHibernate's new mapping by code with SQL Server I'm unable to save an entity. When saving an entity a System.Data.SqlClient.SqlException is thrown with the…
5
votes
1 answer

Set default values in nhibernate-mapping

I am trying to put a default value in a mapping. When I run it says "default" not declared. my code is Is this support for nhibernate Thank you
yohan.jayarathna
  • 3,423
  • 13
  • 56
  • 74
5
votes
1 answer

Collection cannot be null exception when using HashSet in NHibernate

I have the following in my NHibernate entity: private ICollection _stringSet = new HashSet(); public virtual ICollection StringSet { get { return _stringSet; } } Then, in my Fluent mapping I map it…
StarKat99
  • 531
  • 3
  • 15
5
votes
2 answers

NHibernate mappings when self-join relationships have additional properties

How do you map a class to other instances of the same class when that relationship has properties itself? I have a class called Person which is mapped to a table Person PersonID PersonName PersonAge ---------------------------------- 1 …
Iain Holder
  • 14,172
  • 10
  • 66
  • 86
5
votes
2 answers

NHibernate: mapping bidirectional one-to-many with IList semantics

Here are the relevant pieces. This is a parent object: public class Article { public virtual IList Revisions { get; set; } }
Anton Gogolev
  • 113,561
  • 39
  • 200
  • 288
5
votes
2 answers

nHibernate, one to zero or one relationship woes

I have two classes. One is called Employee and the other EmployeeDetails that has a zero or one relationship with its parent 'Employee' class. In other words, there are occasions where we need to store additional data into this 'EmployeeDetails'…
SeanCocteau
  • 1,838
  • 19
  • 25
5
votes
1 answer

Nhibernate - One-to-one mapping with Cascade all-delete-orphan, not deleting the orphan

I have an 'Interview' entity that has a one-to-one mapping with a 'FormSubmission' entity, the Interview entity is the dominant side so to speak, the mapping is:
5
votes
7 answers

Hibernate/NHibernate mapping file editor

I'm looking for an editor that has the help from http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html built in, and allows simple editing of the XML files in a GUI fashion. I realise there's CodeSmith and MyGeneration, but from what I…
Chris S
  • 64,770
  • 52
  • 221
  • 239
5
votes
1 answer

FluentNHibernate: how to Join to table without using primary key

In the following FluentNHibernate mapping: public LawbaseAssetMap() { Table("PRASSET"); Id(x => x.Id).Column("PRA_RECNUM"); Join("PRSTOCK", m => { m.Fetch.Join(); m.Optional(); m.KeyColumn("PRS_ASSRN"); m.Map(t =>…
David
  • 15,750
  • 22
  • 90
  • 150
5
votes
2 answers

NHibernate: mapping entities across multiple DBs on different servers w/o DB link

Using the latest version of NHibernate (and possibly some plugins), is that possible to map entities across multiple databases on different servers without DB link? For the background, I'm looking to implement something loosely similar to what is…
Maxim Gueivandov
  • 2,370
  • 1
  • 20
  • 33
5
votes
1 answer

FluentNhibernate mapping of two tables oneToMany using unique instea of primary key in mapping

I' m writing desktop Project in C#. I'm using Nhibernate to communicate with database. Moreover I use FluentNhibernate into mapping of models but I'm stuck in some part of mapping. Here is My mapping Class in ProductMap Loosing Map public…
5
votes
1 answer

Why do I get the "read-only cache configured for mutable" when building NHibernate session factory?

I have set a simple model: Document entity with multiple images. Images are saved in another database, and they are updated from other legacy application, so my app has only readonly access. I setup a synonim so that I can use the images table on…
Vasea
  • 5,043
  • 2
  • 26
  • 30
5
votes
2 answers

Fluent NHibernate Mapping is set to AllDeleteOrphan but is still trying to null the foreign key in the DB

I'm getting an error with NHibernate when I try to perfrom a ISession.Delete on any table with a One to Many relationship. NHibernate is trying to set the foreign key to the parent table in the child table to null, rather than just deleting the…
CraftyFella
  • 7,520
  • 7
  • 47
  • 61