nhibernate

NHibernate 2.1.1 references an older version of Spring

NHibernate 2.1.0 references Spring 1.3.0. NHibernate 2.1.1 references Spring 0.0.0.2. Is there any special reason for that? I upgraded to NHibernate 2.1.1 and now I'm getting Assembly loading errors. ...

How do you deal with composite pattern when using hibernate and domain-driven design?

Does hibernate has support for hierarchical data in a database where you use a parentId you use a parentId and an orderId you use Modified Preorder Tree Traversal ...

Is it possible to inject custom post processing in the fetching of objects in NHibernate?

Dear ladies and sirs. My scenario is this. We use NHibernate as our DAL. Each and every object fetched by it, be it a single object, a collection of objects or even child objects - whatever, we have to perform certain post processing. Currently, this custom post processing is spread around - after each fetch. I am wondering if I could ...

NHibernate Linq error Could not understand: (ConvertChecked([1003]) = 2)

Hello there, I have a column called TemplateType mapped as follows in my NHibernate library: Map(x => x.TemplateType).Not.Nullable().CustomType(typeof(TemplateType)); //x is an instance of type <Template> So, is mapped to an int column in the database table: Template Now when I am trying to get list of Template objects filtered with...

fluent nhibernate collation conflict

hi, really struggling to resolve this issue. using nhibernate Im trying to join two different tables from two different databases but im getting a collation conflict error. To resolve this issue i know i need to append "collate Latin1_General_CI_AS" to the end of my sql string but have no idea how to do it using nhibernate. Error: Can...

NHibernate for Enterprise applications?

I know that NHibernate works well for projects where you are starting with a fresh database and building from the ground up. In my experience, however, that is not usually the case for enterprise applications. More often than not, integrating of legacy data from other databases is a major part of a new app. Is NHibernate going to be mor...

NHibernate update reference

Entities We have an entity called Product which is loaded using NHibernate. Product has a category which NHibernate happily populates for me. Database In the database, Product has a foreign key for category. Scenario User edits this Product (via a web interface) and chooses a different category (say instead of "Fish" we select "Veg...

Where are the NHibernate/Hibernate HQL and ICriteria query examples?

I'm still quite new to NHibernate and most of it I'm getting to grips with. One area that I'm really lacking a proper understanding of though is querying (at least when it comes to anything reasonably complex). I learn best by example, but I feel that I haven't really been able to find all that many in depth querying examples on the we...

How do I save a new object using NHibernate when it already has an ID?

I'm using GUIDs for the identifier on my objects it is assigned when the entity is instantiated. I want to save them using NHibernate and have NHibernate determine whether it's a new object or not. If it's a new object, it should INSERT it, otherwise it should UPDATE it. How would I do this? ...

Subclasses in separate assemblies with FluentNHibernate

I have a class A in one assembly and subclass B that extends A in another assembly that I am trying to auto-map. There are classes that have relationships to A, and classes that have relationships to B. The subclass strategy is table-per-inheritance-hierarchy. (NOT joined-subclass) Depending on the order of how I add the persistence mod...

Integration test failing through NUnit Gui/Console, but passes through TestDriven in IDE

I am using NHibernate against an Oracle database with the NHibernate.Driver.OracleDataClientDriver driver class. I have an integration test that pulls back expected data properly when executed through the IDE using TestDriven.net. However, when I run the unit test through the NUnit GUI or Console, NHibernate throws an exception saying ...

HQL to SQL converter

Does anyone know how to convert NHibernate HQL to SQL Scripts? ...

triggers with nhibernate

Hi I want to implement auditing using triggers for my web application. I noticed that nhibernate gives error on insert/update single record on table where audit trigger is used. I tried SET NOCOUNT ON option and it worked for me. I need to know what is the disadvantage of using this option with NHibernate. If its not good practice then...

Nhibernate - How to debug "Antlr.Runtime.NoViableAltException"?

With many HQL queries I am trying, time and time again I am getting this exception: Antlr.Runtime.NoViableAltException This is really generic and unhelpful - does anyone know how best to debug this? Obviously it's a problem with my HQL - but without any clue as to what exactly is wrong it's very much a case of trial and error. I'm p...

NHibernate dynamic-update fails to update data changed in interceptor

If I set dynamic-update=true I've found that fields updated in my Interceptor do not get included in the update statement that goes to the database. When I set it to false all the columns including the time stamp get updated. I really want to use dynamic update. public class Interceptor : EmptyInterceptor { public override Boolean OnF...

How to create a criteria in NHibernate that represents an OR between two EXISTS?

Hi, This one has been making my head hurt (which is easy since I'm a NHibernate newbie): how can I represent the following query (T-SQL) through the Criteria API? DECLARE @pcode VARCHAR(8) SET @pcode = 'somecode' SELECT d.* FROM document d WHERE EXISTS ( SELECT 1 FROM project p WHERE p.id = d.projectId ...

How to fluently map tables

i have (2) tables which have primary keys on a legacy db. i want to map non-primary key properties of these tables. for example, USERS PROFILES ----- ------- UserId int ProfileId int Name string ... someId int <-----> someotherId int using Fluent nhibernate, how do i map t...

Testing Data Model in project that uses NHibernate for persistence

I'm still new with NHibernate, so correct me if I'm wrong on any of this. When you are using NHibernate to build collections of objects from database records, NH takes care of instantiating your collections and populating them. How do you instantiate your ISet collections when you are writing tests that don't actually use NH? ...

How can I use Fluent NHibernate Automapping with multiple Lists of the same type in an Entity?

It appears that NHibernate cannot automap more than one IList of a given type in an entity. Consider the following two entities (based on the Examples.FirstProject sample code that is included with the Fluent NHibernate source code). public class Employee { public virtual int Id { get; private set; } public virtual string Fir...

Many-To-One relationships in NHibernate

I am still trying to learn NHibernate best practices, so please be easy on me... :-) I have a Product class with a Many-To-One relationship set up to a Category class. On my Add A Product page, I am loading a DropDownList with the Categories. Now when the user enters the product information and clicks submit, I have to pull down the ...