fluent-nhibernate

Fluent NHiberante - Many To Many Relation

I have Product and Category tables in database. One product can have many categories. One category can have many products. So, I have a third table as ProductCategory, which has ProductID and CategoryID. In Fluent NHibernate, what does the mapping class should look like? For example, For ProductMap class is it correct: HasMany(x =>...

Enum parsing doesn't seem to work with Fluent NHibernate

Hi all I have a data access class with an Enum called Salutation: public enum Salutation { Unknown = 0, Dame = 1, etc Mr = 5, etc } I am peristing the class with NHibernate, and up until this morning I was using .hbm.xml files for mapping. However, I've now switched to using Fluent NHibernate, but loading ins...

fluent Nhibernatetest mappings

Hi there I am using fluent Nhibernate and Id like to write tests for my mappings as shown below I have a scenario where I have a User class, and a UserProfile class The User class is an entity and the UserProfile is a value type, there is a 1:1 relationship between the two. How would I test the mappings based ont this, do I write separa...

Castle.MicroKernel.ComponentNotFoundException : No component for supporting the service Castle.Services.Transaction.ITransactionManager was found

Hi I am using Castle with the Nhibernate Integration Faclility I am running a few tests and they are failing with the error at Castle.MicroKernel.DefaultKernel.get_Item(Type service) at Castle.Facilities.NHibernateIntegration.DefaultSessionManager.ObtainCurrentTransaction() at Castle.Facilities.NHibernateIntegration.DefaultSessionManag...

How to use mapping overrides from many assemblies within FluentNhibernate AutoPersistenceModel generator

Hi All Is it possible to configure the autopersistence model to read mapping and mapping overrides from many assemblies. At the moment I use public AutoPersistenceModel Generate() { var model = new AutoPersistenceModel() .AddEntityAssembly(Assembly.GetAssembly(typeof(User))) ...

Fluent Nhibernate Domain Driven Design

Hi Im curious about how DDD is really implemented using Fluent Nhibernate. for example I have an entity class called User and another class called UserProfile, as far as Im concerned UserProfile is not an entity class but a value type, and should not realy have an identity as such if not associated with a User entity. Now to implement pr...

(NHibernate) PerformSaveOrUpdate event not saving correctly

I have a custom event listener being added (fluently) to my configuration using: .ExposeConfiguration(c => c.SetListener(ListenerType.SaveUpdate, listener)) My listener just captures before a save or update and handles audit fields (CreatedBy, Modified By, etc.) protected override object PerformSaveOrUpdate(SaveOrUpdateEvent sender) ...

Fluent NHibernate - Configure Oracle Data Provider ODP

I am brand new to NHibernate and Fluent NHibernate and I am trying to get the following confguration to work. private static ISessionFactory CreateSessionFactory() { return Fluently.Configure() .Database( OracleDataClientConfiguration.Oracle10.ConnectionString("Data Source=mysource;User ID=myid;Password=mypwd;") ...

Fluent NHibernate fails on Creating Session Factory.

I have used SQL Server 2008 configured in hibernate.cfg.xml file and everything worked fine. Once I tried to use SQLite in memory.. I have having the following issues... hibernate.cfg.xml <?xml version="1.0" encoding="utf-8" ?> <configuration> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory> ...

NHibernate SaveOrUpdateCopy won't insert entity with CompositeId

I have an entity with a CompositeId that won't insert new rows to the database using SaveOrUpdateCopy. The INSERT statement generated by NHibernate is populated with "?" for the value of every field. It inserts fine with SaveOrUpdate, it updates fine with either SaveOrUpdateCopy or SaveOrUpdate, and any entity without a CompositeId ins...

Mapping a backing field, that has a diferent type from the respective property, using Fluent NHibernate

I need to persist this class on database using Fluent NHibernate: public class RaccoonCity { public virtual int Id { get; private set; } public virtual DateTime InfectionStart { get; private set; } private IList<Zombie> _zombies = new List<Zombie>(); public virtual IEnumerable<Zombie> Zombies { get { retu...

How to build a tree in C# given just the child elements?

I have a set of elements that belong to a tree. I only care about the ancestors, I don't care about the children. For example I want the tree to look like this: Barbeque Supplies* Household cleaning Supplies Air fresheners 1. Car Airfreshner* Paper Towels* Utensils Forks* The only input I'm given are the starred elements. So I...

is there a way to do a reverse lookup in nhibernate?

i have two tables: Components ComponentDependencies ComponentDependencies has two columns: ComponentId and ComponentDependencyID. (both foreign keys into Id field of Component table. i am using fluent nhiberate and i have my component object having: public virtual IList<ComponentDependency> Dependencies { get; set; } and in my C...

Why does calling Session.Clear() cause this test to fail?

The following is a simple test of a repository against FluentNHibernate-1.1.0.685 (NHibernate-2.1.2.4000). The Session and NH config are provided by the test fixture. [Test] public void ShouldEdit() { var employee = CreateEmployee(); session.Clear(); var changedEmployee = _testRepository(employee.id); changedEmployee....

uniqueness defined over several columns - FNHibernate

Hi, Is it possible to define a unique constraint over several columns using fnhibernate (I know how to overwrite the mapping etc.)? Thanks. Christian ...

Fluent NH - illegal access to loading collection

In the CategoriesTranslated collection i have this error: illegal access to loading collection. public class Category : Entity { public Category() { CategoriesTranslated = new List<CategoryTranslated>(); } public virtual Category Parent { get; set; } public virtual string Name { get; set; } public virt...

How to quote Fieldnames in Fluent NHibernate 1.1

After upgrading from Fluent NHibernate 1.0 RTM to 1.1 I got some strange errors when creating the database. After some investigation I discovered that FNH 1.0 quoted all field names in the generated mapping files like 'user', but FNH 1.1 did not. This results in errors for the generated sql script when I use restriced keywords for proper...

Fluent nHibernate error CreatingSessionFactory with Oracle

Hi, When I attempt to BuildSessionFactory() I get an error saying it cannot find the following assembles: Could not create the driver from NHibernate.Driver.OracleDataClientDriver, NHibernate, Version=2.1.2.4000 I have a reference to the Oracle.DataAccess version 4.11 in my bin folder and local, I am using: Oracle 10 and Visual Stud...

Mapping a Private Field in NHibernate (with Fluent NH)

Hi friends! I'd like to know, How Could I map (with fluent nhibernate) this model: public class Category { private IList<Product> _products; public IEnumerable<Product> Products { get { return _products; } } /* others properties */ public Category() { _products = new List<Product>(); } // to add...

how to delete/change items in a one-to-many relation

HI all, I'm new to hibernate and I don't know how to handle correctly the updating of items on a one-to-many relation. My scenarion whould be: class image { ILIst Relations; } class Mapping { Image Parent; OwnerId; OwnerType; } When I want to change the images attached to a owner I do: for each 'mappings for Owner X' { del...