Questions tagged [fluent-nhibernate-mapping]

Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

Resources

626 questions
0
votes
1 answer

FOREIGN KEY constraint failed when trying to delete entity referenced in value object

Domain of interest I'm writing a POS software. It has a concept of money transfer means, some of which are physical. Each physical means allows some denominations which are essentially a combination of a face value and a fiat currency. Example: 1…
Spotted
  • 4,021
  • 17
  • 33
0
votes
0 answers

Fluent hibernate and automapper inheritance

I have three entities: BaseEntity (Guid Id) Primary key (for all entities) Person (Name, FamilyName) : BaseEntity Employee (Salary) : Person How to map Employee so that its Primary key was also a foreign key for Person? Should I inherit from…
John
  • 1,834
  • 5
  • 32
  • 60
0
votes
1 answer

Fluent NHibernate Cascade All not saving list of children with composite id

I am trying to save an object Allocation : public class Allocation : DomainEntity { public Allocation() { this.AllocationsTitres = new List(); } public virtual int Id { get; set; } public virtual int…
WizLiz
  • 2,068
  • 5
  • 25
  • 39
0
votes
1 answer

Multiplicity constraint violated Error while loading entity

I've seen this question been asked number of times but each has its own scenario and i couldn't find solution. I wanted to add a table that holds a survey data, and each SURVEY belongs to a SITE. I tried adding a child table Site_Survey such that…
AlphaTry
  • 475
  • 5
  • 27
0
votes
1 answer

NHibernate Delete Many-to-Many Parent and Child

I have 3 classes. Company, Address and Offices. Following are the entities definition. Company: public class Company: Identity { public Company() { Offices = Offices ?? new List(); } public virtual string Name { get;…
0
votes
1 answer

fluent nhibernate one-to-many mapping without References method

Assume I have two classes related by one-two-many: public class Customer { public virtual Guid Id {get; set;} public virtual string Name {get; set;} public virtual IList Orders {get; set;} } public class Orders { public…
Tal
  • 613
  • 1
  • 7
  • 19
0
votes
1 answer

NHibernate set fetch strategy

I'm using NHibernate with fluent api and got MainEntity mapping like this: mapping.References(c => c.Parent1).Not.Nullable().Fetch.Select(); mapping.HasMany(c => c.Children1).Fetch.Select(); mapping.HasMany(c => c.Children2).Fetch.Select(); Then…
0
votes
1 answer

Nhibernate added duplicate column on insert

I'm using Fluent NHibernate. I have a class called Audit which has ItemID property. Everytime that I want to save anything in that table give me this error. Error message: The column name 'itemid' is specified more than once in the SET clause or…
0
votes
1 answer

Nibernate Fluent with interface domain model and inheritance not saving - Unable to resolve property

I have uploaded a gist the has a working sample, the mapping files, and the full debug log that shows the issue - https://gist.github.com/ravensorb/14193136002adbb3ec2fac07c026f921 Here is the actual exception that I am getting: ERR:…
0
votes
1 answer

Fluent NHibernate duplicate row on one-to-many reference

in my project I have a problem with a one-to-many reference. Actually I have three dto referenced to create a many-to-many reference: User one-to-many RoleGroup Role one-to-many RoleGroup A user could have more than one role and so a role could by…
0
votes
1 answer

NHibernate Mapping for string Foreign Key with specific type

I'm trying to map a string foreign key in NHibernate. This works but the field is a varchar(10). This is causing performance problems and the script is timing out because NH is using a nvarchar(4000). When we change the variable type in SSMS to a…
0
votes
1 answer

NHibernate mapping: references with additional constraint

Lets say I have this class public class LinkingTable { public int PrimaryKey { get; set; } public int LinkFk { get; set; } public string LinkTable { get; set; } public OtherTable OtherTable { get; set; } } and some other…
ZrSiO4
  • 116
  • 1
  • 11
0
votes
1 answer

Fluent NHibernate - many to many with additional table - Cannot insert the value NULL Exception during deletion

I have a many-to-many relationship with additional table and when I am trying to delete a A object which also has a reference in AB table below error occur: $exception {"could not delete collection: [A.AB#20][SQL: UPDATE AB SET AId = null…
0
votes
1 answer

Fluent NHibernate Three-Level Sub-Class Mapping

I have a complex NHibernate structure to store our 3 level product hierarchy. When I try and save at level 3 (ProductDetail2), I get the following error: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect):…
0
votes
1 answer

Fluent NHibernate Conventions : OptimisticLock.Is(x => x.Version()) doesn't work

I am having problems with using OptimisticLock as a Convention. However, using OptimisticLock within Individual ClassMap's works fine. It throws Stale State Object Exceptions. Each Class corresponding to a Table in the database has a property (which…