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

Mapping IDictionary with MappingByCode

How can I map IDictionary? I've done this way: Map(x => x.BookedResources, c => { c.Key(ck => ck.Column("ProposedAction")); c.Table("BookedResources"); }, k =>…
0
votes
1 answer

Many-to-many returns no data

I have problem with lazy loading in many-to-many. There is no exception and there are rows in database but lazy loading returns 0 rows. Do you know why? MAPPING:
Eduard Baraniak
  • 421
  • 1
  • 10
  • 31
0
votes
1 answer

Using nHibernate secondary cache for a many-to-one reference

I'm trying to get nHibernate to use second-level cache with a many-to-one relationship, however I can't find any clear explanation on how to set it up correctly. I found this How to get nhibernate to cache tables referenced via many-to-one - is my…
user1198049
  • 491
  • 5
  • 15
0
votes
2 answers

Is it ever a good idea to use NHibernate from a partial many-to-many class?

I have a Shop table, a StaffRole table, and a ShopStaffRole table that serves as many-to-many, but with additional fields like IsRequired, etc. Shop ShopId ShopName ShopAddress StaffRole StaffRoleId StaffRoleName ShopStaffRole …
mo.
  • 4,165
  • 3
  • 34
  • 45
0
votes
1 answer

NHibernate mapping to a 'denormalized' table

I have the following object model (based on a legacy table structure that I can't change). public class Store Contact BillingContact {get;set;} Contact SetupContact {get;set;} ISet Contacts {get;set;} In this scenario, when I…
Steven
  • 860
  • 6
  • 24
0
votes
1 answer

NHibernate Many-To-Many Relationship with Cascades

I have to entities: public class User { public virtual long Id { get; set; } public virtual long Name { get; set; } } public class Group { public virtual long Id { get; set; } public virtual long Name { get; set; } } Mapped as…
Serg Melikyan
  • 369
  • 1
  • 5
  • 7
0
votes
2 answers

defining enum types in a mapping file, or columns from another table

if my mapping file, how would I reference a C# enum type? what about columns from another table?
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
0
votes
2 answers

NHibernate one-to-many not saving children

class A {..} class ContainedA { property of type A and some extra information } class B : A { collection of type ContainedA } As you can tell the idea is to be able to contain a single instance of A in several B's, B itself is also of type A only…
DorD
  • 153
  • 2
  • 12
0
votes
2 answers

nhibernate map item order issue

Hi all i need some ideas how to fix order by map element issue with nullable items. I am trying to do sorting IQueryable q; q = from d in q orderby d.Attributes[1] orderby d.Name select d; //<-- return only devices where device_attrib_value…
Sanja Melnichuk
  • 3,465
  • 3
  • 25
  • 46
0
votes
1 answer

Fluent NHibernate: Table Per Class - Inheritance, how to define other FK-Name?

Here I have the mapping for the parent and child-class: public class Parent { public virtual int ParentId { get; set; } public virtual string ParentName{ get; set; } } public class Child : Parent { public virtual string ChildName{ get;…
sl3dg3
  • 5,026
  • 12
  • 50
  • 74
0
votes
3 answers

NHibernate - Incorrect thinking? Subclassed Model based on Join

I have a simple model class (Part), which pulls from it's information from a single table (t_Part). I would like a subclass of this model called (ProducedPart), that would still utilize NHibernate's caching mechanisms, but would only be instances of…
Brett Veenstra
  • 47,674
  • 18
  • 70
  • 86
0
votes
1 answer

Retrieving tables from "Other users" in nHibernate

First of all I won't to say that I'm an expert in database handling, and less so in oracle. However right now I need to get better at it :) I'm using nHibernate as orm, to my oracle database. It works ok, and is rather simple to use. However now I…
Markus
  • 3,297
  • 4
  • 31
  • 52
0
votes
1 answer

ClassMap to childs of abstract class

I have the following domain model to map using ClassMaps/SubclassMaps A - HasMany -> B (A should be table) B is abstract in code (and should not be a table) C,D,E inherits B and all have very different properties. Each of them should be a table with…
Islandwind
  • 143
  • 2
  • 8
0
votes
1 answer

Mapping in NHibernate 3.2 - Arrays, Custom Lists

Looking at NHibernate 3.2 at the moment and am struggling a little with the mapping by code. Can anyone provide me with a simple example of mapping an array of strings or ints? I can't seem to find any code examples or documentation anywhere that…
David
  • 1,731
  • 24
  • 37
0
votes
1 answer

Mapping Dictionarys containing a List

I'm trying to map a Dictionary containing Lists. I have the following set of tables: CREATE TABLE Item(id) CREATE TABLE Filter(id) CREATE TABLE FilterType(id) CREATE TABLE ItemFilter( item REFERENCES Item(id), filter REFERENCES Filter(id), …
Megacan
  • 2,510
  • 3
  • 20
  • 31