nhibernate-mapping

Fluent NHibernate: How to Map M:N many-to-many with composite keys on both sides

OK, so here is the problem. Its not even as crazy as the guy who wants to map m:n with different column counts in his PKs. No matter what I do or where I look there seems to be no method chain that will result in a successful mapping of this. I have tried doubling up on the Parent and Child columns, eg ParentColumn("").ParentColumn(""...

What's wrong with this NHibernate mapping file?

I am getting a cannot load entity error because of {"Incorrect syntax near the keyword 'File'."} Here is my mapping file. I'm assuming I am not escaping something properly but I don't see what. I don't think it's my PreApplication.File table name. Thanks in advance!! <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="...

Save more than object with the same identifier into a database in the same session?

Hey i have two entiies connected through a many to one realtionship. many[category]---------one[game] columns idgame----------------------gameid category------------------game name I need to have many occureneces of the game primaary key in the category part of the realtionship. I have tried to do this in a session but i get the e...

I want generate INSERT which include my Primary Key (not generated) by NHibernate. How to map Id column for this?

I have table CUSTOMER where CUSTOMER_ID is primary key. Table CREATE TABLE [CUSTOMER]( [CUSTOMER_ID] [int] NOT NULL, [START_DATE] [varchar(30)] NOT NULL, CONSTRAINT [PK_CUSTOMER] PRIMARY KEY CLUSTERED ( [CUSTOMER_ID] ASC ..... Mapping public class CustomerMap : ClassMap<Customer> { public CustomerMap() { With...

What would be the equivalent VB.NET code for this C# FluentNHibernate component mapping?

I'm a C# programmer constrained to write VB.NET code. While exploring NHibernate further for my current client, I encountered FluentNHibernate, which I find real attractive. But now, I wonder how to "translate" this C# code for component mapping into VB.NET code: Component(x => x.Address, m => { m.Map(x => x.Number); m.Map(x =...

NHibernate one shot delete

I'm trying to clear a collection in a parent/child relationship by either clearing the collection (list.clear()) or creating a new instance of the collection on the parent. Similar to this: http://markmail.org/message/mnvooa7g57dlbxta#query:+page:1+mid:mnvooa7g57dlbxta+state:results My test is pretty much identical to the one in the l...

Nhibernate: Component with HasMany

I have this mapping: public sealed class EntityMap : ClassMap<Entity> { public EntityMap () { ... Component(entity => entity.StateHistory, m => m.HasMany<HistoryItem<EntityState>> (Reveal.Property<EntityStateHistory>("Items")) .Table("EntityStateHistory") ...

Newbie problem with NHibernate version 2.1.2.4000 Mapping

I have what appears to be a simple mapping problem in NHibernate, however I have been struggling to find a solution to the problem for a number of days now, and would appreciate some assistance. I am using VB.NET under VS2005. My VS2005 solution structure is as follows: Solution: PsalertsIP Project (Assembly): Core Folder Data (Nam...

Modeling one to zero or one relationships (Z cardinality)

I'm struggling to find the best way to model 1 : 0,1 relationships ("may have one" or "has at most one"). I believe this is called Z cardinality. For example, suppose I have two classes Widget and WidgetTest. Not all Widgets are tested and the test is destructive so there can be at most one WidgetTest per Widget. Also assume that it's i...

Fluent nhibernate mapping problem: many to many self join with additional data

I am struggling with mappings for the following sql tables |Post | |PostRelation | |------------------| |-----------------| |PostId |1--------*|ParentPostId | |---other stuff--- |1--------*|ChildPostId | | | |RelationType | Ideally Id l...

Use Component as IDictionary index in AsMap in Fluent Nhibernate

I currently have the following property on an object: private IDictionary<ExampleKey,ExampleObject> example; where ExampleKey is public class ExampleKey { public long KeyField1{ get; set;} public long KeyField2{ get; set;} } This maps with hbm with the following syntax: <map name="example" inverse="true" cascade="all-dele...

Modeling an organizations hierarchy then been able to map details of each different organization in Nhibernate

We are trying to model a school system hierarchy from State>County>District>School, hence we are using the model below to describe the parent child relationship along with organization type (i.e. School, District,…). Organization Hierarchy Now we need to store details on each particular organization, for example if it’s a school we n...

How to map IDictionary<string, Entity> in Fluent NHibernate

Possible Duplicate: Use Component as IDictionary index in AsMap in Fluent Nhibernate Hi, I have an class with an IDictionary on it. <map name="CodedExamples" table="tOwnedCodedExample"> <key> <column name="OwnerClassID"/> </key> <index type="string" column="ExampleCode"/> <many-to-many class="CodedExa...

NHibernate Not Compile on my Window Server

My Apps was developed with NHibernate Working fine on my system but giving this error on the host Server Index was outside the bounds of the array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in t...

How do I override the automapping for a composite Id, one to many relationship with fluent nhibernate?

I'm polling mulitple systems (domains) for security info so I'm dealing domainUsers and their roles. I've got my entities setup as show below, but I'm having trouble setting up the domainUser.HasMany relationship in the AutoMapper override. You'll notice that I don't have domainUser.DomainUserId and role.RoleId which make this much m...

Fluent Nhibernate and Dynamic Table Name

Hi, I've got a parent and child object. Depending on a value in the parent object changes the table for the child object. So for example if the parent object had a reference "01" then it will look in the following table "Child01" whereas if the reference was "02" then it would look in the table "Child02". All the child tables are the sa...

NHibernate and parent/child collection mapping

Hi, I have this table containing both parent and child elements. CREATE TABLE Expenses( [BudgetId] int, [AccountGroupId] int, [AccountNumber] int, [Amount] decimal ) In my domain model it's represented by this hierachy: Budget AccountGroup ExpenseLine ExpenseLine ExpenseLine So a Budget has a collection of A...

How to use Dynamic Instantiation with ICriteria in Nhibernate?

I know that you can do this easily with HQL using the following syntax: "select new ItemRow(item.id, item.name) from ..." In this example, the ItemRow need not be a persistent class that has its own mapping class. But how can we accomplish the same using ICriteria? ...

Properly mapping a polymorphic relationship with NHibernate

I am trying to create a table-per-hierarchy mapping using NHibernate 2.0.1. I have a base class with properties that exist for each subclass that other classes inherit from. All of these objects are persisted to one table called Messages that contain all of the possible fields for each class. There is a SourceID which is the discriminat...

Using Time columns with NHibernate, Fluent NHibernate and SQL Server 2008

Hello, I have a table with a time column in my SQL Server 2008 database. The property of the object I'm trying to map to is a TimeSpan. How can i tell FluentNHibernate to use the TimeAsTimeSpan NHibernate type, so that I don't have cast problems? ...