nhibernate-mapping

NHibernate 2.1 App looking for 3.0 Reference?

Hello All, I have an odd problem. I have a number of C# apps that utilize Nhibernate 2.1. Within the last 2 days I've begun receiving the following error: Could not load file or assembly 'NHibernate, Version=3.0.0.1001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest defin...

NHibernate - Best way to map to a secondary key

I am trying to map a new domain model to a fixed-schema legacy database and am stuck on how to do a certain type of mapping. Here's a distilation of my problem. There are types of Workers. For example an HourlyWorker and a SalariedWorker. The data for an HourlyWorker is stored in the WORKERS table and the HOURLY_WORKERS table with a ...

NHibernate On Legacy Database How To Tell NHibernate Which Is The Parent Table

I have two tables in a legacy database... tblParentTable (int id, string specialIdentifier, ...) tblChildTable (int id, string specialIdentifier, ...) As you can see, an auto-incrementing int id has been added, but the child table is joined using the old string primary key (in fact, specialIdentifier is the primary key of tblParentTab...

NHibernate HQL join query for list of entities returning duplicates

I am attempting to query entities with HQL in order to return a list of objects. The query returns the correct number of rows, but the first entry (ie the first row returned is duplicated across all entities). What could be the cause of this problem? The HQL query is using (ISession session = NHibernateHelper.OpenSession()) { ...

nHibernate - Complicated many-to-many class mapping

Hi All I'm new to nhibernate, and I'm sorry if this is answered elsewhere, but I've been looking for the last couple of hours, and can't find a solution that works. A bit of background: I'm trying to write an Admin area where there are users and sites, and a user can have access to multiple sites - but at various permission levels for ...

Deleting a many-to-many relationship results in a delete and an insert queries

Hello all, I have an entity called Strategy, and another one called Team. Both are mapped using a Many-To-Many relationship: public class Team : BaseEntity<Team> { private readonly IList<Strategy> allStrategies = new List<Strategy>(); public void AddStrategy(Strategy strategy) { allStrategies.Add(strategy); ...

Saving manually created objects using NHibernate

Hi, I am trying to use NHibernate to save an object that was completely manually created. My mappings are in place and I currently have no data in the database. Everytime I call Save() or SaveOrUpdate(), NHibernate does a select statement for what I am trying to save. Then it gives me the exception: "a different object with the same ...

Mapping multiple discriminator values to single default class in NHibernate

I have an existing RoleType table with data. I am trying to map this table in NHibernate using Table per class hierarchy: <class name="IRoleType" table="RoleType"> <id name="Id" column="RoleID"> <generator class="native" /> </id> <discriminator column="RoleID" /> <property name="Description" column="Description" /> ...

Configure NHibernate to compile mappings "on the go"

By default, NHibernate compiles the mappings when creating the SessionFactory... Is it possible to configure NHibernate so that it compiles the needed mappings "on the go"? So that it only compiles a mapping when it needs it? The reason I'm asking is to work around the lenghty operation on start-up (of a winforms, well, AutoCAD applica...

Why NHibernate auto-truncates instead of throwing an exception on save?

Hi, I have been studying the Summer Of NHibernate Tutorials and when I have reached the Session 04: Exploring Transactions and Concurrency -just like in the tutorial- I wanted to create a SAVE test which should fail because of an invalid object. The purpose is to test if it can rollback the transaction properly. Idea is to create an i...

How can I stop Fluent NHibernate from creating foreign keys

I got a polymorphic relationship like the following example: public class A { public virtual Guid Id { get; set; } public virtual string Name { get; set; } } Class B & C contining a List of A's: public class B/C { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual IList<A>...

Nhibernate - How to Design DomainObjects and Mappings with CompositeId

Hi, at first i'm really new to ORM, nhibernate and FHN. i look into this stuff for a few days now. i have an existing database with 4 tables: so i tried first to get the Auswahl and RefAuswahlFilter to work. here are my DomainObjects: pls let me know when i can do this better [Serializable] public class Auswahl { public Auswahl...

Mapping a property to another table using NHibernate.

I have a users table that is updated by other systems. I have mapped the table to my users objects and that work great. As user data is owned by another system I don't want to change the structure of that table. I want to add metadata to the user objects, but without changing the structure of the users table. I want to add a flag that t...

Sending grid-data using nHibernate entities and DTOs

We are using nHibernate in our domain model, and would like to create DTOs for sending objects over WCF to a front-end application made using the MVVM-pattern (WPF/WinForms). We have total control of both the client and server - and both are upgraded at the same time, so versioning/cross platform is not an issue. I see how editing singl...

Ignore property mapping by accessbility in Fluent NHibernate AutoMapper

I have the following class which I am mapping using Fluent NHibernate's AutoMapper. I do not want the list items publically modifiable so have a public IEnumerable backed by an IList which can be populated internally or by NHibernate. I want NHibernate to map teamMembers to a column named TeamMembers. I also want FNH to ignore the TeamM...

Nhibernate mapping conditional

I have the following tables and i have no control on the table schema DocumentText { NoteId OutputType Note_Text } OrderCoordinator { AuthoriserCode Value } DocumentText joined to OrderCoordinator on (Note_Text = AuthoriserCode) only when Outputtype='PRTYPE' How do i map this using fluent nhibernate i am currently mapping ...

How to map HasMany using non Primary Key column?

Hi I use Castle.ActiveRecord's HasMany mapping. I have something like: [HasMany (typeof (childtype), ColumnKey = "this_relation_column", Table = "childtype_table")] I would like to use a different column on childtype_table to relate with this_relation_column. Actually, this_relation_column is of type text (string), and the PK of child...

Issue with Casting proxies when using NHibernate table per subclass inheritance strategy

Hi guys, I have got an abstract base class and inherited poco entities. I am using table per subclass inheritance with fluent nhibernate 1.1 automapping. The class inheritance looks like follows Node (abstract class) Place : Node Asset : Node Node class is basically a tree structure. public abstract class Node { publi...

NHibernate mapping many child entities to one entity

I currently have a bookings model such as: public class RoomBooking : Entity, IBooking { public virtual Client Client { get; set; } public virtual Address Address { get; set; } public virtual IList<BookingPeriod> BookingPeriods{get;set;}... public class BookingPeriod : Entity { public virtual IEnumerable<IBooking> Book...

NHibernate mapping child collection and embedded instance of child

Hi, I'm trying to figure what's the correct way to map the following parent child relationship. I have a parent class which contains child objects. However, the parent also has a pointer to an instance of one of the children (the PrimaryChild) Class Parent Public Property Id As Integer? Public Property PrimaryChild As Child Pu...