nhibernate

Turning automatic nulls off for inserts to FoxPro tables through NHibernate using JetDriver isn't working.

I'm using NHibernate with Burrow and Fluent to shuttle data from SQLServer2005 into a directory full of FoxPro 7 dbf's. When I try to save a new record through Burrow's GenericDAO, I get an exception that boils down to "Field XXX does not accept null values," where field XXX is a NOT NULL field that is not being mapped at all because it...

Automapping subclass in Fluent NHibernate

I'm having some trouble getting fluent nhibernate to properly map the class hierarchy that I have. Presuming that I have the following class structure public abstract class MedicationAction { ... Id and other attributes public virtual MedicationStatus MedStatus { get; protected set; } } public class CeaseAction : MedicationActio...

NHibernate: receiving index out of range while calling flush for insert operation

I've spent the better part of my day trying to solve this message while using NHibernate: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" My update and delete work just fine but the call to flush after a call to save() does not work. I don't think it will be useful to post a...

ASP.NET MVC with NHibernate

I want to know few things about ASP.NET MVC with NHibernate. Is NHibernate the best ORM used with ASP.NET MVC? If so, will NHibernate slow down the application? What can be done to improve performance of an ASP.NET MVC application with NHibernate? ...

Ado.net transaction scope, NHibernate and multiple servers

Hi all, I am currently working on an enterprise solution, which hosts several applications and due to that I implemented NHibernate to work with several session factories. I created a custom section like: <hibernate-sessionFactories> <sessionFactories> <clear/> <add name="Server1" factoryConfigPath="~/SessionFactoryCo...

Map dynamic/generic properties with NHibernate

I have a scenario where I have a propertybag of key/values that would look something like: Entry 1 : key="Load", value="2", type="int" Entry 2 : key="DailyStatus", value="0", type="bool" I am trying to figure out if it's possible with nhibernate to map these values to a single table that I can pull out at a later time into .net simple...

Mapping a single field to multiple tables with Fluent NHibernate

I have the following domain graph, representing an insurance claim which can be against a vehicle or property: public enum InvolvedPartyContext { Vehicle = 1, Property = 2 } public class Claim { public virtual Guid Id { get; set; } public virtual InvolvedPartyContext InvolvedPartyContext { get; set; } public virtual...

Adding a new column to a may to many relationship in NHibernate

Hi. A have this mapping: mapping.HasManyToMany(x => x.SubVersions).ParentKeyColumn("ParentId").ChildKeyColumn("SubVersionId").Table( "VersionLinks"); This will create a table VersionLinks with 2 columns(ParentId,SubVersionId). Is it possible to have in this table another column (ex. CreateDate) that will be filled autom...

Escape SQL Parameter

I need to work around an NHibernate bug I reported here. Essentially, NHibernate will generate multiple SQL parameters for the same HQL parameter, which results in problems for queries that use a parameter in a grouping construct. Until the bug is fixed, I figured I'd just concatenate the parameter into the HQL. Obviously this is suscep...

Using NHibernate DetachedCriteria in WCF (Known-Types Problem)

Hello, I am trying to pass a DetachedCriteria of NHibernate to a WCF Service. I get a strange error, I think it is something WCF specific. I solved the actual problem by "manually" serializing the class (see code). But I would like to know how to solve the real problem, that the second function runs.. The error message is: There was a...

How do I retrieve a list of base class objects without joins using NHibernate ICriteria?

Let's say I have a base class called Pet and two subclasses Cat and Dog that inherit Pet. I simply map these to three tables Pet, Cat and Dog, where the Pet table contains the base class properties and the Cat and Dog tables contain a foreign key to the Pet table and any additional properties specific to a cat or dog. A joined subclass ...

Objects validating itself using Castle Validators

hi, I have a Task object which has a property of Employee. Im trying to find the best possible way setting a validation to only allow the certain employees to access the task object. If the current context user (web/winforms) tries to instantiate the Task object the object should automatically validate itself and return a validation er...

Getting Count when using DetachedCriteria/DistinctRootEntity

update: After not getting anywhere with this, I noticed that when I pulled the queries out into two distinct criteria, the actual hydrated objects returned were correct, but the count query was returning the joined dataset. So the question is: How do I use Projections.RowCount in conjunction with CriteriaUtil.DistinctRootEntity and a D...

Generate C# entities from existing DB and Fluent NHibernate auto mapping

I'm working with an existing database that uses some really ugly conventions. I'd like to use NHibernate, and I think I can fix all these ugly DB conventions using Fluent NHibernate's auto mapping conventions. I'd like to avoid writing all the entity classes by hand. (This is where LINQ to SQL and SubSonic are appealing) Is it possib...

NHibernate: How to map a sorted many-to-many relationship

I'm trying to work out the best method (i.e. most simple and foolproof) for mapping a many-to-many collection that should be sorted when it is retrieved. Here is the basic entity and table: public class Person { private IList<AddressHistoryRecord> _addressHistory = new List<AddressHistoryRecord>(); IList<AddressHistoryRecord> ...

How to map this legacy table with NHibernate (Fluent)?

New to NHibernate. Having trouble wrapping my head around how to map this legacy table. CREATE TABLE [dbo].[CmnAddress]( [addressId] [int] NOT NULL, [objectType] [varchar](63) NULL, [objectId] [int] NULL, [addressType] [varchar](7) NULL, [recordStatus] [char](1) NULL, [fromDate] [int] NULL, [toDate] [int] NULL, [onStreet] [varchar](254...

<Component> Update NHibernate

I have some mapping: <class name="SomeItem" table="items" lazy="false"> <id name="Id" type="Int32" column="id"> <generator class="identity"/> </id> <property name="Name" column="EventName" type="String"/> <property name="Description" column="EventDesc" type="String"/> </class> <class name="ItemCount"> ...

NHibernate and Modular Code

We're developing an application using Nhibernate as the data access layer. One of the things I'm struggling with is finding a way to map 2 objects to the same table. We have an object which is suited to data entry, and another which is used in more of a batch process. The table contains all the columns for the data entry and some addi...

nhibernate hql with named parameter

I have implemented a search function using Castel Active Record. I thought the code is simple enough but I kept getting NHibernate.QueryParameterException : could not locate named parameter [searchKeyWords] errors. Can someone tell me what went wrong? Thanks a million. public List<Seller> GetSellersWithEmail(string searchKeyWords) ...

NHibernate -failed to lazily initialize a collection of role.

I have the following seemingly simple scenario, however I'm still pretty new to NHibernate. When trying to load the following model for an Edit action on my Controller: Controller's Edit Action: public ActionResult Edit(Guid id) { return View(_repository.GetById(id)); } Repository: public SomeModel GetById(Guid id) { using ...