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

NHibernate "Errors in named queries"

I have the following named SQL query defined:
Kevin Pang
  • 41,172
  • 38
  • 121
  • 173
7
votes
1 answer

Getting NHibernate error Exception of type 'Antlr.Runtime.NoViableAltException' was thrown

I'm having some issues with a query of a table that includes a space in it's name If i write a sql-query it works fine, ie SELECT * FROM [product groups], but when using NHibernate CreateQuery everything breaks using (ISession session =…
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
7
votes
3 answers

Nhibernate : Map all decimals with the same precision and scale

I understand that in NHibernate, using mapping by code, I can specify the precision and scale of a decimal property like so: Property( x => x.Dollars, m => { m.Precision(9); m.Scale(6); } ); That is…
A.R.
  • 15,405
  • 19
  • 77
  • 123
7
votes
4 answers

NHibernate.MappingException: Could not compile the mapping document

I'm newbie in NHibernate. I'm trying using this ORM with SQLite. I have the following: Product.cs namespace Stock.Models.Classes { class Product { public virtual string Name {get; set;} public virtual int Id { get; set; } …
Cristhian Boujon
  • 4,060
  • 13
  • 51
  • 90
7
votes
1 answer

Why does NHibernate delete and recreate all associations in a collection when I add one item to it?

I'm doing some tests using NHibernate and I currently have two mapped entities, Orders and Products. As always an Order has a collection of Products, and I'm mapping this as:
Thomas C. G. de Vilhena
  • 13,819
  • 3
  • 50
  • 44
6
votes
0 answers

Fluent NHibernate Has Many to Many Convention Questions

I am new to fluent nhibernate and nhibernate. I want to write a fluent nhibernate autopersistence convention to handle creating the many to many mappings for my entities. This is what I have right now: using System; using…
6
votes
2 answers

Time and Nhibernate

hello i got an application that uses nhibernate as orm, i need to store data that represents time, whats the best way to do it? nhibenate dont know to convert time field from db to a timespan, only string.
Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141
6
votes
2 answers
6
votes
1 answer

How to allow auto-imports="true" when we use Nhibernate 3.2's mapping by code?

I have to use an HQL query in my project and I've an error : "entity is not mapped". When I read nHibernate HQL - entity is not mapped or nHibernate HQL - entity is not mapped (or other web site) I can read that I have to use auto-import="true" on…
P. Sohm
  • 2,842
  • 2
  • 44
  • 77
6
votes
1 answer

How to set "cascade delete" option to "Set Null" in Fluent NHibernate?

I am new to Fluent nHibernate and would like to know, if I have two classes Profile and Email mapped one-to-many as following... I want to define a nHibernate mapping fluently so when Profile is deleted, Email will remain in the DB, with a key set…
Alex Cherkasov
  • 192
  • 2
  • 9
6
votes
1 answer

NHibernate Join Fetch(Kind)

Given a Team -> Athlete relationship and querying all athletes. What am I misunderstanding about fetch="Join"? Should this mapping cause the Team to be loaded via a join? When iterating the athletes, it still lazy loads the Team. public class…
mxmissile
  • 11,464
  • 3
  • 53
  • 79
6
votes
1 answer

Fluent nHibernate Join is doing insert into joined table

I am trying to use join to pull in a single property from another table, which doesn't have a mapping. My problem is that when I create a new instance of my mapped entity and save it I get an error about trying to insert into my unmapped table…
Ben Tidman
  • 2,129
  • 17
  • 30
6
votes
3 answers

Converting string to double in fluent-nhibernate mapping

I have a sql table with a string column that could contain null, empty string or a double value. I want to map this column to a C# property that is a double, defaulting to zero when the column is null or empty. Can I do this with a fluent-nhibernate…
Mike
  • 857
  • 1
  • 16
  • 29
6
votes
3 answers
6
votes
2 answers

setting type and length on composite-key property in fluent nhibernate

In hbm mappings I can [..] How do I do that (setting type and…
Nils
  • 9,682
  • 6
  • 46
  • 72