fluent-nhibernate

Generate XML mappings from fluent Nhibernate

How do I generate xml mappings files as part of my tests in MappingIntegrationTests I need to manually check if the fluent mappings correlate to the mappings in the leagcy project. ...

Can we stop the ID column from auto-incrementing?

Hi, I have a table with primary column as an ID. But that column is not an identity column. All the values are provided explicitly. Below is my mapping class public ObjectTypeMap() { Table("OBJECTTYPE"); Id(x => x.ObjectTypeId); Map(x => x.Title).Not.Nullable(); Map(x => x.Description); } but ...

Twin Lucene index directories after Nhibernate.Search upgrade

Hello everybody i've been busy upgrading our n* stack to a more recent version. We'd been using FluentNhibernate for configuration and Nhibernate.search coupled with Lucene.Net for full-text search. Everything worked fine until i changed the various versions of the libraries to the following: FluentNHibernate.dll: 1.0.0.593 NHibernate...

NHibernate: Map one class to two identical tables

I need to map one entity to two tables (Invoice and InvoiceHistory). It's not up to me to merge the two database tables in one and add a status column to differentiate them. The two tables have the exact same structure, but, as the name says, InvoiceHistory keeps a history of old invoices whereas Invoice stores active invoices. (the ex...

Unit test fluent nhibernate ordered list mapping

I get an exception when I try to unit test an ordered list with fluent nhibernate. The code seems to run ok but my PersistenceSpecification fails! System.ApplicationException: Expected 'CareerNote.Core.Model.Section' but got 'CareerNote.Core.Model.Section' at position 0 The full code is on github: http://github.com/fodonnel/CareerNote...

NHibernate L2 Cache - fluent nHibernate configuration

I've managed to configure the L2 cache for Get\Load in FHN, but it's not working for queries configured using the ICriteria interface - it doesn't cache the results from these queries. Does anyone know why? The configurations are as follows: ICriteria: return unitOfWork .CurrentSession .CreateCriteria(typeof(Country)...

NHibernate SessionFactory Configuration

When we configure the Nhibernate session factory, with fluentnhibernate, we can add the mapping files using AddFromAssembly, AddFromAssemblyOf, or Add. The first two scan the assembly for the ClassMaps. Probably there is no considerable difference, but which one is the best in terms of reducing the sessionfactory creation time? Maybe «Ad...

Configuring ASP.NET MVC 2 with Spring.NET and FluentNHibernate

Hello, I'm trying to configure ASP.NET MVC 2 RC and Spring .NET 1.3 to use FluentNHibernate. I've managed to get FluentNHibernate running inside console application. At moment ASP.NET MVC 2 RC and Spring .NET are working fine for me, but I'm having trouble configuring FluentHibernate. Before asking this question I have Googled a lot...

NHibernate filter criteria - Hour of DateTime

I am having hard times convincing NHibernate (EF was able to do it) to filter based on the Hour property of a DateTime entity property. My entity goes something like : public class Invoice { // ... public DateTime Time { get; set; } // ... } I need to retrieve all the invoices that were "made" at a certain hour (let's say ...

learning nhibernate (with or without fluent)

Hello, I am going to try using NHibernate, the reason I stayed away from NHibernate so far was the xml-mapping part. Now that (I found out) there is fluent nhibernate, looks like we don't need to do xml mapping. But I am wondering if starting with some xml mapping, would be more helpful in learning and getting comfortable with NHibernat...

FluentNHibernate: What is the effect of AsSet()?

In Fluent Nhibernate what is the effect of specifying AsSet() on a HasMany or HasManyToMany relationship? Assuming the type of the mapped property is an Iesi Set, is there any difference between: HasMany(x => x.MySetProperty) .AsSet(); and HasMany(x => x.MySetProperty); ...

Fluent NHibernate: ManyToMany Self-referencing mapping

Hi, I need help in creating the correct fluent nh mapping for this kind of scenario: A category can be a child of one or more categories. Thus, resulting to this entity: public class Category : Entity, IAggregateRoot { [EntitySignature] public virtual string Name { get; set; } public virtual IList<Category> Parents { get; s...

Add multi-column unique constraint on foreign Key using fluent-nhibernate automapping

Hi everybody, I'm an NHibernate and fluent-nhibernate newbie. And I've got some problem with unique constraint and nhibernate mapping. I've got the following part of domain model. public class Batch { public virtual int Id {get; set;} public virtual string Name {get; set;} public virtual IList<BatchParameter> BatchParamete...

[Nhibernate] CreateQuery and CreateCriteria generating different SQL queries

Client has a Report, Configuration etc properties. A client can have only one of each. Also, each report can belong to only one Client. This is in a way a one-to-one relationship. Therefore my Report table has a foreignkey column clientID. Same for the Configuration and other tables. Now as per the definition of one-to-one that i read ...

Problem with Nhibernate.Bytecode.Castle in MSBuild (TFS)

We have a Fluent NHibernate mapping test that is passing on our local machines, but when we check in to TFS, the tests are failing on the build server. We are using MSTest. The error we get is: NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.By...

Fluent Nhibernate How to specify Id() in SubclassMap

Hello, I'm in the process of adapting Fluent NHibernate to our existing legacy app and am trying to determine how to use ClassMap and SubclassMap for the entity hierarchy shown. // BaseObject contains database columns common to every table public class BaseObject { // does NOT contain database id column public string CommonDbCol...

NHibernate number format problem - where do I set the culture?!

LATER EDIT : It was me :( It was a non-nullable column left unfilled. Sorry to everyone I confused.. I am having issues with an INSERT statement generated by NHibernate because it formats the decimal numbers using the regional settings. The generated statement goes something like : exec sp_executesql N'INSERT INTO [TableName] ( Co...

Is NHibernate SchemaUpdate safe in production code?

For simplicity's sake. I'm using Fluent NHibernate's Automapping combined with NHibernate's SchemaUpdate during runtime. On each run Automapper creates mappings for all entity classes and SchemaUpdate applies the schema to the existing database. I was pleasantly surprised that it works correctly against an empty database as well. It's wo...

How do I get fluent nhibernate to save "null" to the db for uninitialized variables

I have a class like this: public class test { public virtual int Id { get; private set; } public virtual char testType { get; set; } public virtual char testType2 { get; set; } } When I create this, but don't specificy testType2, I want the value to be "null" in the database. Instead, the value is an empty char. One way th...

Fluent NHibernate mapping a reference to a column that is not the ID column.

I am using Fluent Nhibernate 1.0 with Sharp Architecture 1.0 Currently I am trying to map a reference to a ZipCode class. The current class I am mapping has a ZipCode column, but the zipcode class is much more extensive than what is needed for a basic zipcode, hence the reasoning behind this. (Basically Zipcode class contains lat. and...