nhibernate-mapping

How to create reference using a non primary key column

Hi, All I have two entities: public class A : EntityWithTypedId { Guid UniqueIdentifier; IList<B> Children; } public class B: EntityWithTypedId { A Parent;..... } I want to make the reference using the Guid column not the primary key Id (so I will have in the B table UniqueIdentifier not A_id). I can't make it to work for ...

Fluent NHibermate and Polymorphism and a Newbie!

I'm a fluent nhibernate newbie and I'm struggling mapping a hierarchy of polymorhophic objects. I've produced the following Model that recreates the essence of what I'm doing in my real application. I have a ProductList and several specialised type of products; public class MyProductList { public virtual int Id { get; set; } pu...

Three-Way Many To Many Mapping in NHibernate

Hi, I was often directed to this blog site when I was researching on NHibernate and a lot of times I got my answers. I have a question today. I appreciate any assistance. What I am facing now is this: a simple mapping table in our database has foreign key references to three tables. The three referenced tables are: State, Organization...

Fluent NHibernate automap a HasManyToMany using a generic type

I have a bunch of domain entities that can be keyword tagged (a Tag is also an entity.) I want to do a normal many-to-many (Tag -> TagReview <- Review) table relationship but I don't want to have to create a new concrete relationship on both the Entity and Tag every single time I add a new entity. I was hoping to do a generic based Ta...

Is it possible to Load hbm.xml info at app startup instead of via an embedded resource?

Possible Duplicate: adding an nHibernate mapping at run time? All of the NHibernate examples I've see that use hbm files have the hbm.xml file set as an embedded resource with "do not copy" chosen in the file properties. This means that if a database column name were to change in production, the app would have to be recompiled...

NHibernate mapping with no empty constructor and no setters

I'm testing how difficult it is to use NHibernate with a domain that is completely unaware of it and isn't bent to accodomate any limitations. On many examples I found on the web the domain being mapped is yet another example of an anemic domain, where objects don't go far from being simple data holders. Sure, this makes the mapping sim...

Nhibernate: Stop it from joining to a table that is not needed

I have two tables (tbArea, tbPost) that relate to the following classes. class Area { int ID string Name ... } class Post { int ID string Title Area Area ... } These two classes map up with Fluent Nhibernate. Below is the post mapping. public class PostMapping : ClassMap<Post> { public PostMapping() ...

nHibernate storage of an object with self referencing many children and many parents

I have an object called MyItem that references children in the same item. How do I set up an nhibernate mapping file to store this item. public class MyItem { public virtual string Id {get;set;} public virtual string Name {get;set;} public virtual string Version {get;set;} public virtual IList<MyItem> Children {g...

Anyone know of any decent resources on Stored Procedures for Fluent Nhibernate 1.1

A recent release of Fluent Nhibernate (1.1) now supports stored procedures. I was wondering if anyone out there has found any good blog articles on how to do this! I am not asking about using classic hbm mappings instead which these questions previously asked: http://stackoverflow.com/questions/296732/does-fluent-nhibernate-support-map...

[N]Hibernate: view-like fetching properties of associated class

(Felt quite helpless in formulating an appropriate title...) Is it possible to define a mapping for a class such that some properties are fetched from another table using a join query? In my C# app I display a list of "A" objects, along with some properties of their associated "B" objects and properties of B's associated "C" objects: ...

Nhibernate - Referencing transient objects in disconnected sessions.

Hi, I've been banging my head against a brick wall for nearly two days on this so any help would be great. The scenario I've got is basically this. I have an object called Campaign which I'm creating from scratch in a web client. The Campaign has a reference to another object, Portal. The Portal has been pulled from the database thr...

How to order a HasMany collection by a child property with Fluent NHibernate mapping

I am using Fluent NHibernate to map the following classes: public abstract class DomainObject { public virtual int Id { get; protected internal set; } } public class Attribute { public virtual string Name { get; set; } } public class AttributeRule { public virtual Attribute Attribute { get; set; } public virtual Statio...

Mapping One-to-One subclass in Fluent NHibernate

I have the following database structure: Event table Id - Guid (PK) Name - NVarChar Description - NVarChar SpecialEvent table Id - Guid (PK) StartDate - DateTime EndDate - DateTime I have an abstract Event class, and a SpecialEvent class that inherits from it. Eventually I will have a RecurringEvent class which will inherit from the E...

nhibernate - mapping with contraints

Hello everybody, I am having a Problem with my nhibernate-mapping and I can't find a solution by searching on stackoverflow/google/documentation. The database I am using has (amongst others) two tables. One is unit with the following fields: id enduring_id starts ends damage_enduring_id [...] The other one is damage, which has the ...

Fluent NHibernate: Foreign Key violation or Null values.

Hey guys, I am having some real issues with mapping using fluent nhibernate. I realise there are MANY posts both on this site and many others focusing on specific types of mapping but as of yet, I have not found a solution that solves my issue. Here is what I have: namespace MyProject.Models.Entites { public class Project { ...

Fluent NHibernate: Example of a one-to-many relationship on an abstract class of a table-per-subclass implementation

Hi All, I've been trying for ages to find an example (because I can't get it to work myself) of the correct mapping for a one-to-many relationship on an abstract class of a table-per-subclass implementation, in fluent nHibernate. An example below: I'm looking to map the list of Fines on the Debt abstract base class to the Fine class. ...

NHibernate Mapping Attributes + Spring

Hello everyone, I'm working on a C# .NET project in which I am mapping my classes to the tables in my database with NHibernate. I need to use NHibernate.Mapping.Attributes and transactions to be configured by Spring. The fact is that Spring 1.3.0 provides a sample project called "Spring.Data.NHibernate.Northwind" that almost provides a...

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 read on the wiki how to do the mapping. But when I add the mapping of the subclass an NHibernate.DuplicateMappingException is thrown when it is mapping. Why? Here are my (simplified) classes: public abstract...

nhibernate fluent bool to smallint mapping

In my application I have a bool property named DisplayIndicator. In the database (DB2) it's correspondence is DISPL_IND column of type smallint. The correspondence is the following: [DisplayINdicator=True, DISPL_IND=1] and [DisplayINdicator=False, DISPL_IND=0] Is it possible to map using nhibernate fluence the bool property to smallint?...

Fluent Nhibernate - Mapping two entities to same table

Hi, I'm trying to map two domain entities to the same table. We're doing a smart entity for our domain model, so we have the concept of an Editable Address and a readonly Address. I have both mapped using Classmaps, and everything seems to go fine until we try to export the schema using the SchemaExport class from NHibernate. It erro...