fluent-nhibernate

Fluent NHibernate - Map 2 tables to one class

Hello, I have two tables that I want to map to one class that will looks like: CUSTOMER_INFO_CLASS.cs ---------------------- Id (CUSTOMER table) CustomerName (CUSTOMER table) CustomerTypeDesc (CUSTOMER_TYPE table) I tried to do it with join, as follows: Table("CUSTOMER"); Id(x => x.ID).Length(10).Column("CustomerId"); Map(x => x....

NHibernate: why doesn't my profiler query correspond to my fluent mapping?

I have this fluent mapping: sealed class WorkPostClassMap : ClassMap<WorkPost> { public WorkPostClassMap() { Not.LazyLoad(); Id(post => post.Id).GeneratedBy.Identity().UnsavedValue(0); Map(post => post.WorkDone); References(post => post.Item).Column("workItemId").Not.Nullable(); Reference...

NHibernate mappings issue when referencing class (lazy load issue?)

I'm using NHibernate + Fluent to handle my database, and I've got a problem querying for data which references other data. My simple question is: Do I need to define some "BelongsTo" etc in the mappings, or is it sufficient to define references on one side (see mapping sample below)? If so - how? If not please keep reading.. Have a look...

Is it possible to use varying CurrentSessionContexts within a fluent configuration?

I'm currently setting up my session configuration via a static call such as SessionConfiguration.GetSessionConfiguration(); The method above returns a configured ISessionFactory: public static ISessionFactory GetSessionConfiguration() { return Fluently.Configure() .Database(MsSqlConfiguration .MsSql2005 ...

No persister for entity using AutoMap in Fluent Nhibernate?

I'm trying to utilise FluentNHibernate with Automapping but am receiving the following error No persister for: nHibernateSpike.Entities.Route NHibernate.MappingException: No persister for: nHibernateSpike.Entities.Route Here's the relevant stuff; var model = AutoMap.AssemblyOf<Route>(). Where(t => t.Namespac...

Fluent nHibernate - unfriendly many-to-one reference name

I define my data model using Fluent nHibernate POCO classes + mappings. I'm also using nHiberate schema to create database schema. All is working fine but there is one unpleasent fact. When I use many-to-one reference referece is named by something similair to GUID instead of any descriptive name. Here's a piece of SQL: alter table [Odb...

Fluent; SessionSource or SessionFactory for creating sessions?

I'm using NHibernate + Fluent to handle the database in my application. So far I've been using a SessionSource to create my ISession objects. I'm a bit confused now about what comes from NHibernate or Fluent, and what I really should use for creating my sessions. ISession comes from NHibernate, and the SessionSource from Fluent. I crea...

Can we execute script file against databse using fluent Nhibernate?

Hi, I want to execute script file on my database using fluent nhibernate. Can you tell me how can i achieve this? I have a file say "myScript.sql" on my c drive, which i want to execute against my oracle database. Thanks in advance, Ashish ...

NHibernate L2 Cache configuration in Fluent NHibernate

Is ti possible to configure the L2 cache provider in code via FHN? Adding a line to the following config is what I'm after: return Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(c => c.FromConnectionStringWithKey("Temp")).ShowSql()) .Mappings(m => m.FluentMappings.AddFromAs...

Nhibernate Inserting when should be update after adding Event Listener

I have a Custom EventListener hooked into listen for SaveOrUpdates and now whenever I call Session.SaveOrUpdate on my object it inserts when it should update. Here is my Event Listener: public class CustomSaveEventListener : DefaultSaveEventListener { protected override object PerformSaveOrUpdate(SaveOrUpdateEvent @event) { ...

SharpArchitecture - FluentNHibernate Schema Generation?

Hello. I'm trying out SharpArchitecture and want to have FluentNHibernate generate my database schema for my MVC WebSite. I'm a bit lost on where to do this. I can do it by adding the SchemaUpdate thingy in the global.asax.cs-file right after NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession); in "Ap...

NHibernate identifier altered exception

Hi, I am trying to import some large files using batch queries and paralel processing and I'm constantly getting errors like NHibernate.HibernateException: identifier of an instance of xxx was altered from ... to ... I know I am not modifying my primary key at all. I am using NH 2.1.x GA, ThreadStaticSessionContext, every file is proc...

Fluent NHibernate (with automapping) not saving join table values in many-to-many

I am not exactly an NHibernate expert, so this may be a lack of understanding in that department. I have two simple entities with a many-to-many relationship public class Category { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public ...

Can Fluent NHibernate's AutoMapper handle Interface types?

I typed this simplified example without the benefit of an IDE so forgive any syntax errors. When I try to automap this I get a FluentConfigurationException when I attempt to compile the mappings - "Association references unmapped class IEmployee." I imagine if I were to resolve this I'd get a similar error when it encounters the ...

NHibernate and database changes/deployment

I'm looking into using NHibernate and Fluent NHibernate for my next project but one thing I'd like clearing up before hand is how do you manage changes to the database? eg, I have NH + FNH working, application has been deployed and is live but we make a change in the development environment, for example say we add a new property to a en...

Fluent NHibernate Mapping test takes forever

I've recently started to learn Fluent NH, and I'm having some trouble with this test method. It takes forever to run (it's been running for over ten minutes now, and no sign of progress...). [TestMethod] public void Entry_IsCorrectlyMapped() { Action<PersistenceSpecification<Entry>> testAction = pspec => pspec ...

DateTime precision in NHibernate and support for DateTime2 in NHibernate SchemeExport

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO class: public class Foo { public virtual int Id { get; set; } public virtual datetime CreatedDateTime { get; set; } } The CreatedDateTime field will map to a SQL DateTime by default. However if I do a test to check ...

NHibernate Cascade none still updating related entity.

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO classes: public class Webpage { public virtual int Id { get; set; } public virtual string UrlIdentifier { get; set; } public virtual WebpageType WebpageType { get; set; } } public class WebpageType { public vi...

how to ignore a property by attribute in nhibernate

How can i ignore a property by decorating a property with an attribute? the base class AttributePropertyConvention doesn't seems to have that ability, or can it? Doesn't find anything sutiable on IPropertyInstance to set.. ...

(Fluent) NHibernate composite-id problem : MySQL complains that the parameter index is out of bounds

I'm using Fluent NHibernate to create an ASP.NET MVC project, with Submissions and Votes (Up/Down) by Users. Of course, Users can vote submission Up or Down. To record this, I created a middle table, SubmissionVote, which contain the following fields: submissionId (int) userId (int) score (enum: up/down) Here are my mappings: Submis...