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

NHibernate navigators mapped to the part of a composite key problem - legacy database usage

We have a legacy database that we cannot change. And we are trying to move to the NHibernate instead of old DataAccess layer which is a garbage and is too slow. it has tables like these: GPI table has (PU_ID, PAR_ID, Data, Data2) columns BLOCK table…
6
votes
2 answers

Inner or Right Outer Join in Nhibernate and Fluent Nhibernate on Many to Many collection

How can I force NHibernate to do a RIGHT outer join or an INNER join instead of a LEFT outer join on a many to many collection? The reason I would want to do this is because of filtering applied to the collection elements. With a left join, you get…
snicker
  • 6,080
  • 6
  • 43
  • 49
6
votes
2 answers

NHibernate DuplicateMappingException when mapping abstract class and subclass

I have an abstract class and subclasses of this, and I want to map this to my database using NHibernate. I'm using Fluent and how to do the mapping. But when I add the mapping of the subclass an NHibernate.DuplicateMappingException is thrown when it…
stiank81
  • 25,418
  • 43
  • 131
  • 202
6
votes
5 answers

NHibernate: One base class, several mappings

I'm relatively new to NHibernate, but have been using it for the last few programs and I'm in love. I've come to a situation where I need to aggregate data from 4-5 databases into a single database. Specifically it is serial number data. Each…
anonymous
  • 6,825
  • 8
  • 47
  • 60
6
votes
1 answer

NHibernate: deleted object would be re-saved by cascade. Replace object and remove old one

I'm trying to replace at TimeBlock object on a ProgramItem and then delete the old TimeBlock object. It's the delete part that gives me problems. I have some 'relative' simple nHibernate problems deleting the old TimeBlock object. Exception: deleted…
Morten Holmgaard
  • 7,484
  • 8
  • 63
  • 85
6
votes
1 answer

FluentNHibernate - ClassMap vs IAutoMappingOverride

In FluentNHibernate when should I use ClassMap and when IAutoMappingOverride for my EntityMap classes. public class PostMap : ClassMap { public PostMap() { ... } } vs public class PostMap :…
Fitzchak Yitzchaki
  • 9,095
  • 12
  • 56
  • 96
6
votes
1 answer

How can I use Fluent NHibernate to discriminate on a column of a parent relationship

I have this entity relationship. public abstract class UserGroup { public virtual int UserGroupId { get; set; } public virtual int GroupType { get; set; } public virtual string GroupName { get; set; } public virtual…
6
votes
1 answer

Working with Time Type in Fluent Nhibernate generates exception "Unable to cast object of type 'System.DateTime' to type 'NHibernate.Type.TimeType"

I founded that NHibernate have several builtin Types that are not present in C#, but are present in some of SGBD. Now I have following: public class TimeSlot : EntityBase { public virtual NHibernate.Type.TimeType FromTime { get; set;…
Nic
  • 1,088
  • 3
  • 19
  • 43
6
votes
1 answer

nhibernate does not cascade delete children

The scenario is as follows, I have 3 objects (i simplified the names) named Parent, parent's child & child's child parent's child is a set in parent, and child's child is a set in child. mapping is as follows (relevant parts) parent
6
votes
2 answers

Nhibernate doing updates on select?

I have the following class: public class Product { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual Decimal PricePerMonth { get; set; } public virtual BillingInterval DefaultBillingInterval { get;…
Morten Jacobsen
  • 986
  • 1
  • 11
  • 31
6
votes
2 answers

Receiving Index Out of Range with NHibernate

I'm hoping that someone can help me with this issue. I've been racking my brain and my project is due very soon. Thank You in advance. I'm receiving an index out of range exception when inserting a new record. After searching endlessly for…
user134363
6
votes
1 answer

Invalid index 6 for this SqlParameterCollection with Count= 6

Map Class public class cAdministratorMap : ClassMap { public cAdministratorMap() { Table("Administrators"); CompositeId(c => c.Key) .KeyProperty(x => x.Client_id,…
6
votes
3 answers

NHibernate "illegal access to loading collection" error

What is the reason of this error? My class is Course and it has notes. Mapping is as below. Any idea?
NetSide
  • 3,849
  • 8
  • 30
  • 41
6
votes
1 answer

How can I use Fluent NHibernate Automapping with multiple Lists of the same type in an Entity?

It appears that NHibernate cannot automap more than one IList of a given type in an entity. Consider the following two entities (based on the Examples.FirstProject sample code that is included with the Fluent NHibernate source code). public class…
6
votes
1 answer

Map foreign key in Fluent NHibernate without object property

My question is, is there a possible Fluent NHibernate mapping for Parent and Child objects that does not require the Child object to have a Parent object property? I haven't figured out how to map the reference back to the Parent. When I call Create…
Annie B
  • 637
  • 1
  • 9
  • 14