fluent-nhibernate

How can you create Clustered Indexes with Fluent NHibernate?

I am using Fluent-NHibernate (with automapping) to generate my tables but would like to choose a different clustered index than the ID field which is used by default. How can you create clustered indexes with Fluent NHibernate on a field other than the default Primary Key field? The primary reasoning behind this is simple. I am using Gu...

Fluent NHibernate primary key constraint naming conventions

Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. ...

Issue With Fluent Nhibernate Automapping and Guids / UniqueIdentifiers as Primary Key Fields

I am attempting to use the Fluent-NHibernate automapping functionality (in the latest version of the software) and am running into problems using Guids as the Primary Key fields. If I use integer fields for the primary keys, the tables are generated successfully and all Nhibernate functionality seems to work fine. FYI, I am using NHibern...

Fluent code for mapping an IDictionary<SomeEntity, int>?

I'm trying to figure out how to map an IDictionary property in fluent 1.0 RTM. From my understanding this translates to a ternary association. Example: class Bar { public IDictionary<SomeEntity, int> Foo {get; set;} } Bar.hbm.xml would then contain: <map name="Foo" table="BarFooTable"> <key column="..."/> <index-many-to...

Overriding Fluent NHibernate Automappings

This is a Fluent NHibernate newbie question, so bear with me. I have a set of classes, and I'm applying the Automapping capabilities to it. But I need to mark one of the properties of one of the techniques with a Unique constraint. In the Fluent Wiki, it says Sometimes it's necessary to make slight changes to a specific entity,...

setting Fluent NHibernate Conventions - using Set for OneToMany

I am trying to modify the Automapping conventsion in Fluent NHibernate to use ".AsSet" for OneToMany mappings, rather than ".AsBag" (which, judging from the hbm files exported, appears to be the default). I have spent hours pouring over the documentation, and I understand that I need to do a "AutoMap.AssemblyOf<T>().Conventions.Add<Cu...

NHibernate HiLo ID generator is performing a round-trip to the database per-row inserted

When I configure my application to use HiLo Id generation, I see one round-trip per row inserted in the database. All the documentation I've read has indicated that I should see far fewer round-trips. My objects are all generally configured (fluently) as such: Id(t=>t.Id).GeneratedBy.HiLo("MyObject_Identity","MaxId","1000"); Addition...

Does FluentNH's PersistenceSpecification allow XML mappings to be tested?

Is it possible to use Fluent NHibernate's PersistenceSpecification to test NHibernate mappings done via XML? ...

Fluent NHibernate / NHibernate Mappings

I have a parent table and relationship table to find child parent relationship. I need to find child, parent and its siblings... EMPLOYEE_RELATION has columns EMPLOYEE_ID and PARENT_ID that saves the relationship. Here's what SQL looks like. How do I map this to Fluent NHibernate / NHibernate. select V1.PARENT_ID AS PARENT_ID, ...

Nhibernate Inheritance baseclass issue

Hi, I have what I think should be a fairly simple mapping issue, but not having any luck figuring out what I'm missing to make it work. I'll just jump into a simple example to get to the point of what I'm trying: //Base user class public class UserBase : Entity { //properties user class should have } // //Concrete User class (in di...

How can I access a property with a protected setter in my asp.net-mvc controller from fluent-nhibernate?

Using S#arp Architecture 1.0RC... I have a controller that never seems to update one of my properties. My class is a User abstract class with a Manager property. Manager is subclasses from User, as is Employee. I declared the property setter for Manager as protected and provided a method to AddManager. That way, I could also control t...

How to map this in Fluent.NHibernate

I'd like to get this output from fluent.nhibernate <map name="Dict" table="TABLE"> <key column="ID_USER" /> <index-many-to-many column="ID_TABLE" class="TableClass" /> <element column="COL" type="Int32" /> </map> where class has: public class User { public virtual IDictionary<TableClass, int> Dict { get; protected set; } }...

Fluent NHibernate Automapping Bi-directional relationships

Hi, I am trying to automap my domain model using fluent nhibernate. In this particular case I have a bidirectional one-to-many relationship that i need to map. Problem is that it doesn't automatically realize it as a bidirectional relation but as two different relations altogether and creates a separate foreign key for each. How do I t...

NHibernate questions - modifying this example for Fluent NHibernate

Hi, I'm new to NHibernate... I have been following this NHibernate Tutorial from Gabriel Schenker : http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx However, this tutorial uses hbm files. I would like to know - what do I need to do to modify the hepler class below (which creates a session factory) so that...

Fluent mapping - entities and classmaps in different assemblies

When using fluent configuration to specify fluent mappings like this: .Mappings(m => m.FluentMappings.AddFromAssembly(typeof(UserMapping).Assembly)) At the moment I am getting a "NHibernate.MappingException : No persister for" error. Is it a problem that my Entities and my ClassMaps are in different assemblies? Presumably AddFromAss...

Mapping a single row result through a linking table with filter in FNH

Excerpts from an existing schema: User Table: PK int UserId, string UserName, etc Vendor Table: PK int VendorId, string VendorName, etc UserVendor Table: PK int UserId, PK int VendorId, PK bit IsPrimary //note the composite key There is no FK between User and UserVendor (don't ask, it's a legacy database). I'd like to produce a Us...

Simple FluentNHibernate parent/child mapping

New to FluentNHibernate =D I have a parent/children classes as follows: public class Parent { public virtual int ID { get; private set; } public virtual string Name { get; set; } public virtual IList<Child> Children { get; set; } } public class Child { public virtual int ID { get; private set; } public virtual stri...

Mapping tree structure with Fluent NHibernate

I am having trouble to map a tree structure using Fluent NHibernate, without also having to put in what I believe is a hack. Consider the following classes: Node (abstract, has int Id and GroupNode Parent (if null, the node resides in the root node)) GroupNode (inherits from Node, has IList<GroupNode> Groups and IList<ItemNode> Items)...

Storing a field in FluentNHibernate using one type, but accessing through methods as another type

I am creating a message queue in a database. Each queued item stores a ID and a couple of other things. But the key field is IncomingMessage. In the database I am storing a serialized version of the IncomingMessage because it can be one of a number of types (like NewWorkorderMessage or EmployeeStatusChangeMessage). So the field in my Que...

Table of Unique Strings with Fluent NHibernate

I have a class Item and a class ItemAttribute, where Item has a property of type ItemAttribute. ItemAttribute only has two properties, a Guid called ID and a string called name. The idea here is that I want to store a table called ItemAttributes that contains a list of unique strings. My question is, if I save an Item that references a...