nhibernate

IDbCommand's not being properly enlisted in NHibernate transaction

I have two IDbCommand objects that are created from an NHibernate session, and they are enlisted in a transaction via the NHibernate session. The first database command inserts a value into an Oracle global temporary table and the second command reads values from the table. With an Oracle GTT, a transaction is needed for both commands ...

IoC - WindsorContainer - Asp.Net null after Application_Start

I have a situation where I user IoC (WindsorContainer) in a .Net web application, and in the Global.asax I register my container, but straight after I register my WindsorContainer I also need to Instantiate another Class (Oauth) in the Global.asax. However because I use the Sharp Architecture and Nhibernate on IIS7 it makes the situatio...

DetachedCriteria with 3 OR conditions

How can I achieve this query using DetachedCriteria: Select * from MyTable Where (conditionA = true) or (conditionB = true) or (conditionC = true) or (conditionD = true) ...

Handle NHibernate Transaction Errors

Our application (which uses NHibernate and ASP.NET MVC), when put under stress tests throws a lot of NHibernate transaction errors. The major types are: Transaction not connected, or was disconnected Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) Transaction (Process ID 177) was deadlocked on...

How can I see the SQL call to the Db done by NHibernate?

Hi, How can I see the SQL call generated and passed to Db by NHibernate? I have in my hibernate.cfg.xml file this line: <property name="show_sql">false</property> any idea? thanks ...

Why Nhibernate cannot create this simple query for me?

Hi, I cannot understand why this simple query is not created. I call this method from a test and it throws an exception complaining about line 1, column 7 where I cannot see anything wrong. public IList<Continent> GetContinentByName(string name) { ISession session = GetSession(); IQuery query = ...

Unusual NHibernate collection/inheritance mapping

Hi! Here are my relevant classes: public class ArticleMetadata { public long ID { get; set; } public string Slug { get; set; } } public class Article : ArticleMetadata { // This is a massive CLOB, hence separate class public string Content { get; set; } } public class Section { public long ID { get; set; } p...

Is this the right way of using ThenFetch() to load multiple collections?

I'm trying to load all the collections eagerly, using NHibernate 3 alpha 1. I'm wondering if this the right way of using ThenFetch()? Properties with plural names are collections. The others are just a single object. IQueryable<T> milestoneInstances = Db.Find<T, IQueryable<T>>(db => from mi in db whe...

NHibernate. Map 1-many Relationship to Dictionary.

Hi I'm trying to map a one-many parent-child relationship in NHibernate using XML mapping. Easy enough if the parent class instances store the collection of children in a list, but I want to use a dictionary. Can anyone point me to an example that shows how to set up this mapping in XML? In other words I want my parent class to look lik...

ORM and NH for business people

I have to prepare a case to convince managers to promote development using an ORM. I don't want to go into technical details in this case, the benefits have to be visible to business people. I'm not quite happy with the arguments I've written down until now Are there any points I'm forgetting, both PRO and CONTRA? The case I'm going to...

What is wrong with this HQL query in version 2.1.2.4 of NHibernate?

So the below hql query is throwing an Antlr.Runtime.NoViableAltException. I was able to determine that issue is with the member.LastName field in the order by clause. If remove member.LastName from the order by the query will execute. This HQL worked just fine in an earlier version of NHibernate, but it broke with the upgrade to NHiberna...

Domain Modeling question / collections with NHibernate

Hi, Please consider the domain model shown below (simplified for brevity - no ids etc.) A Customer can comment on a Product only once. Lets assume (for reasons I don't want to get into here) that the Customer class cannot have a collection of Reviews that it owns. The Product is the main Aggregate root here. Often in this situation,...

How to get the parameter declarations as well as the SQL calls of NHibernate?

Hi, When I am working with NHibernate (I am a beginner of it btw) I am able to obtain the SQL calls to Db in my output. But I am not able to make them work after I copy and paste into Management Studio. Because it is missing the parameter declarations. I get something like: SELECT this_.PK_Product as PK1_1_0_, this_.ProductCode as P...

Nhibernate Projection Query DTO, use method in stead of property

Hey, This works: projections.Add(Projections.Property(Member<MailOrder>.From(x => x.AssigneeCode).QualifiedPath), Member<MailOrderItem>.From(x => x.AssigneeCode).Path); projections.Add(Projections.Property(Member<MailOrder>.From(x => x.AssigneeName).QualifiedPath), Member<MailOrderItem>.From(x => x.AssigneeName).Path); proj...

Any good example on Implementation of spring.net + NHibernate + Repository pattern

Are there any good example on implementation of Spring.net with NHibernate and Repository pattern? Currently I'm going through below url's. http://www.springframework.net/doc-latest/reference/html/orm.html#orm-hibernate-web ...

Query performance fluctuation

Hello there, i'm running queries from NHibernate and have my profiler set up to trace any slow queries, there are a few which seem to take 10+ seconds in my profiler mainly: exec sp_executesql N'SELECT top 50 this_.Debiteur_ID as Debiteur1_44_6_, this_.Debiteurnaam as Debiteur2_44_6_, this_.Debiteurnummer as Debiteur3_44_6_, this_.IsBed...

Why is NHibernate refusing to batch inserts?

Using NHibernate 2.1.2.4000 against SQL Server 2008. The target table has no triggers or extraneous indexes. It is simply: create table LogEntries ( Id INT IDENTITY NOT NULL, HostName NVARCHAR(32) not null, UserName NVARCHAR(64) not null, LogName NVARCHAR(512) not null, Timestamp DATETIME not null, Level INT not null,...

ASP.NET MVC - NHibernate - DropDownLists

Hi, i am just getting started with ASP.NET MVC and i'm using NHibernate for my data context. I have kept the foreign key fields in my entity classes so that it could hopefully making working with drop down lists easier but this is not the case. Here is my post back action: var user = userRepository.GetById(id); if (!TryUpdateModel(us...

How can the NamedSQLQueryDefinition class be used dynamically as a sql-query equivalent?

I need to dynamically add named queries to the NHibernate configuration object. The search engines return few hits referencing NamedSQLQueryDefinition or NamedQueryDefinition. Below is what I'm attempting to do. I don't know what to provide to the NamedSQLQueryDefinition constructor to successfully create a query. Can anyone provide a sa...

Mapping collection of enum in NHibernate.

Hi all! I have a class with collection of enums: Class1.cs public enum Language { Serbian = 1, Croatian, Ukrainian, } public class Class1 { private IList<Language> m_languages = new List<Language>(); public virtual IList<Language> Languages { get { return m_languages; } set { m_languages = val...