fluent-nhibernate

How do I get NHibernate to do a join?

I've used Fluent NHibernate to hook up a store and employee class where Stores can have many employees as follows: public class Store { public virtual IList<Employee> Employees { get; set; } //other store properties } public class Employee { public virtual Store Store { get; set; } public virtual bool? SomeStatus1 { ...

Fluent NHibernate - Many To One Relation

There is a table of Products and Categories. Many products have one category. So, in Product mapping, how can I write the correct code to map with its category? In Product class: Is it something like: References(x => x.Category).Column........ ...

inheritance with fluent nhibernate

Hi This question is really to establish if what im trying to achieve is possible. I have three tables i'll omit the actual names to keep it simple and less confusing so we have Person [ PID - uniqueidentifier PK ] Applicant [ PID - uniqueidentifier PK, AID - varchar(20)] Student [ PID - uniqueidentifier PK, SID - int] both the s...

Error with Nhibernate: System.Data.SqlClient.SqlException: Incorrect syntax near 'Index'

Hey all, i have an nhibernate solution and i'm trying to do a save, but i'm getting this error: Test method HelloMusic.Core.Test.CrudTests.TestTrackAdd threw exception: NHibernate.Exceptions.GenericADOException: could not insert collection: [HelloMusic.BLL.Track.Credits#20][SQL: INSERT INTO Tracks_Credits (TrackID, Index, CreditID) VA...

'table per subclass' or 'table per class hierarchy'

Hi, I am using FNHibernate and its default is 'table per subclass' for inheritance mapping. This seems to be the cleanest way to do things but it has its downsides too. My problem is that I have to seed the database with lots of tab separated data. I have tried to do this via repositories/services (i.e. via FNHibernate) but this is ver...

Fluent NHibernate mappings for Domain objects with interface typed reference (in a S#arp arch app)

I'm trying to code my domain to interfaces types rather than concrete types. Skeleton examples of two domain objects are: public class Supplier : ISupplier { public virtual IContract Contract {get; set;} } public class Contract : IContract { public virtual List<ISuppliers> Suppliers {get; set;} } Is there a way to Fluently ma...

NHibernate, how to map a property to a subselect

I currently have a legacy system that uses SPs exclusively for access to the DB. My domain object looks something like this: public class User : EntityBase { public virtual string Name {get;set;} public virtual string CreatedBy {get;set;} public virtual DateTime CreatedDate {get;set;} } The SP I have that mapped this looke...

Fluent NHibernate JoinedSubClass is obsolete

Hello! I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap, but if I do this the AutoMapping does not work, and I don't want that. Is there an...

How to export hbm xml files using s#arparchitecture with fluent mappings

This question was asked before but the answers all show how to export the hbm files from fluentnhibernate. We are using S#arpArchitecture which wraps fluent. I am able to export the schema but what I really want is the xml files to troubleshoot errors. I've done this using FNH before but adding S#arp to the mix has complicated things wh...

Fluent NHibernate not querying the database correctly

Hi, i have just looked into hooking my application into nhibernate (fluent nhibernate) but i am having a few difficulties... I have tried to follow what people have done and found this: public class NHibernateSessionPerRequest : IHttpModule { private static readonly ISessionFactory _sessionFactory; static NHibernateSessionPer...

How can I stop System.OutOfMemoryException on bulk insert.

Hi I am bringing about 100000 records into memory cleaning the data and inserting into a new table. After inserting around 2000 records I get the following exception. A first chance exception of type 'System.OutOfMemoryException' occurred in Iesi.Collections.DLL A first chance exception of type 'FluentNHibernate.Cfg.FluentCon...

Quoting column names with NHibernate and PostgreSQL

I have started to use NHibernate 3.0 and PostgreSQL for a small project, so far the ride has been a little rough due to the NHibernate site being down and I'm sure this answer is on their website somewhere. I have a database that has these two columns(of course there is more in the real table): int ID String Feature now I'm using a F...

Nhibernate Generat wrong SQL for Oracle with locking

yesterday I've been trying to make this code work inspite the fact it's just working fine with nhibrnate and SQL server but when it come to oracle it generate wrong sql UnitOfWork.Current.CreateCriteria<Bill>().Add(Restrictions.IsEmpty("ReqId")) .SetMaxResults(BatchSize).SetLockMode(LockMode.Upgrade).List<Bill>(); the generated SQL w...

NHibernate: Default value for a property over a null column

hi all! I'm working with an old database used by other applications, so i can't modify its structure. Sometimes i have nullable columns that i want to map as a non nullable type. For instance I have a nullable EndValidity column on database which i want to map on a non nullable DateTime, and, if null, it should be DateTime.MaxValue, or a...

How can I map a value in fluent nhibernate to a column that doesn't exist.

Basically my object doesn't have a LastupdateDate field but the database does and requires is to be mapped. Does anyone have an idea how I could map the 'lastupdatedate' column without changing the AClass class? This is a basic table.......... ATable { id INT, lastupdateDate DATETIME } Business class that is maps to...................

Why are some references missed when running my application?

I have the following project structure using a Domain Model, StructureMap and Fluent NHibernate: The problem I'm having is that Fluent NHibernate requires all of the following to be the bin directory of the website for it to work at runtime: Antlr3.Runtime.dll * Castle.Core.dll Castle.DynamicProxy2.dll FluentNHibernate.dl...

FluentNhibernate Mapping: Bidirectional one-to-many on same entity (Tree Mapping)

Hi, I want a bidirectional mapping in one class, in which the child can choose its parent (and save it to the database). How would I model that? This is what I have: public class MyNodeMap : ClassMap<MyNode> { public MyNodeMap () { Table("myTreeTable"); Id(x => x.Id).Column("NotParentId").GeneratedBy.Ident...

StaleStateException when changing id in nhibernate

Very new to NHibernate so I expect there will be a quick fix here. The code I'm looking at has an unorthodox design. public class Partner { public virtual int Id { get; set;} //note the set is not private public virtual String Name { get; set;} } and is mapped with FluentNhibernate's Automappings When Partner is created its ...

Need help with a 'No persister for:' exception with Fluent Nhibernate Automapping

Hello I'm having some problems with applying NHibernate Fluent Automapping. It worked great in a test project. But now.. Test method [PROJECTNAME].SubscriptionTest.SubscriptionConstructorTest threw exception: NHibernate.MappingException: No persister for: [PROJECTLIB].SubscriptionManagerRP The class (then again, the same exception a...

Unmapped property in a mapped class (Fluent NHibernate 1.1)

Background Fluent NHibernate 1.1 (with a repository implementation using LINQ to NHibernate) in an ASP.NET MVC 2 project using Ninject. I have a mapped class (Station) with a collection of another mapped class (Report). I would also like Station to have a convenience property (MostRecentReport) that returns the Report for that Station ...