nhibernate

NHibernate LINQ + PLINQ

Hi i've just started reading up on PLINQ and find it fasinating. I'm using NHib->Linq in my projects - does anyone know if there's any benefit/problems using PLINQ type queries with NHLinq? w:// ...

Nhibernate and not-exists query

I'm trying to construct a query in NHibernate to return a list of customers with no orders matching a specific criteria. My Customer object contains a set of Orders: <set name="Orders"> <key column="CustomerID" /> <one-to-many class="Order" /> </set> How do I contruct a query using NHibernate's ICriteria API to get a list o...

Which one have better performance?

I write same query with two approach by using NHibernate: 1- by using HQL like below public long RetrieveHQLCount<T>(string propertyName, object propertyValue) { using (ISession session = m_SessionFactory.OpenSession()) { long r = Convert.ToInt64(session.CreateQuery("select count(o) from " + typeof(T).Name + " as o" + "...

Why can event handlers can only be bound to HttpApplication events during IHttpModule initialization?

This is just another "working in dev server, why not working in IIS" type question. I created a nice DAL using NHibernate as described here. When creating an ISession, I hook up an event handler to the HttpApplication.EndRequest to take care of cleaning it up. However, I deployed my site to IIS and it says: Event handlers can only be ...

NHibernate propagate key column on save

I'm using hibernate with the following class <composite-id name="ID" class="HomePersonID"> <key-property name="Country" column="country" type="int" /> <key-property name="Home" column="home" type="int" /> </composite-id> <many-to-one name="Person" class="Person" cascade="none" fetch="select"> <column name="country" /> <column...

Global.asax parser errors when deploying MVC 1 application to remote server.

So we're having some issues deploying an ASP.NET MVC app to a client site. Basically when we try to test the app from localhost, we get the dreaded Global.asax parser error indicating it could not load the application global. Research indicates there are basically 4 possible reasons for this exception we're seeing: The solution hasn'...

Log4net duplicate logging entires

I recently switched out log4net logging from using config files to being set up programmatically. This has resulted in the nhiberate entries getting repeated 2 or sometimes 3 times. Here's the code. It uses a string which looks something like this "logger1|debug,logger2|info" private void SetupLog4netLoggers() { IAppe...

NHibernate CreateSQLQuery data conversion from bit to boolean error

Hi, Im being a bit lazy in NHibernate and using Session.CreateSqlQuery(...) instead of doing the whole thing with Lambda's. Anyway what struct me is that there seems to be a problem converting some of the types returned from (in this case the MySQL) DB into native .Net tyes. The query in question looks like this.... IList<Client>...

nHibernate Criteria for selecting all entities with emtpy child collections

I'm having difficulty writing a Criteria to select all entities with empty child collections or empty grand-child collections. I can do these as seperate Criteria but I'm having trouble combining into a single Criteria. class structure: public class Component { public IList<Version> Versions { get; set; } } public ...

How to map it? HasOne x References

Hi everyones, I need to make a mapping One by One, and I have some doubts. I have this classes: public class DocumentType { public virtual int Id { get; set; } /* othes properties for documenttype */ public virtual DocumentConfiguration Configuration { get; set; } public DocumentType () { } } public class D...

nservicebus deleting subscription record after inserting it?

I have been playing with nservicebus for a few weeks now and since everything was going well on my local machine I decided to try to set up a test environment and work on deployment. I am using the generic host that comes with nservicebus and was using the nservicebus.Integration profile when running locally, but would like to use Nservi...

Using NHibernate with an EAV data model

I'm trying to leverage NH to map to a data model that is a loose interpretation of the EAV/CR data model. I have most of it working but am struggling with mapping the Entity.Attributes collection. Here are the tables in question: -------------------- | Entities | -------------------- | EntityId PK |-| | EntityType |...

How do I serialize/deserialize a NHibernate entity that has references to other objects?

I have two NHibernate-managed entities that have a bi-directional one-to-many relationship: public class Storage { public virtual string Name { get; set; } public virtual IList<Box> Boxes { get; set; } } public class Box { public virtual string Box { get; set; } [DoNotSerialize] public virtual Storage ParentStorage { ge...

NHibernate: References still being eagerly selected after specifying AddJoin

I have a query which is something like this: Session.CreateSQLQuery( @"SELECT f.*, b.*, z.* FROM Foo f LEFT OUTER JOIN Bar b ON b.Id = f.BarId LEFT OUTER JOIN Zar z ON z.Id = b.ZarId" ) .AddEntity("f", typeof(Foo)) .AddJoin("b", "f.BarId") .AddJoin("z", "b.ZarId") .List<Foo>(); The problem is that I ...

Get subclass type from projection with NHibernate

Hi I am trying to do a projection on a type called Log. Log references a superclass called Company. Each company type is mapped with table per subclass. Is it possible for me to get the type of Company when I do a projection on Log? I currently have an Enum property (which is not mapped) on each subclass, so I can perform switches on C...

Enums with NHibernate

What's the recommended way to store enums with NHibernate? To put it another way, should I use the Enum type in the property of the model? it's ID (int)? Or a string? I would like to know from a Fluent NHibernate perspective. ...

Simplest way of generating new DB tables from Fluent NHibernate?

Given: A DB (containing data), a set of model entity objects, and working NHibernate (fluent) mappings. What is the easiest way to generate the required new DB tables, when new model entities and mappings are added? ...

fluent nhibernate not caching queries in asp.net mvc

I'm using a fluent nhibernate with asp.net mvc and I not seeing anything been cached when making queries against the database. I'm not currently using an L2 cache implementation. Should I see queries being cached without configuring an out of process L2 cache? Mapping are like this: Table("ApplicationCategories"); Not.LazyLoad(); C...

NHibernate will insert but not update after move to host with shared server running mysql.

Hi, I have a site running MVC and Nhibernate (not fluent) using standard session per request in an http module, runs fine locally (also with mysql) but after a move to a hosting provider no update statements are being issued. I can insert but not update, no exceptions are raised, I have the 'show_sql' option switched on which locally s...

how to ensure that Nhibernate is inside a transaction when saving, updating or deleting

I'd like to ensure that when I'm persisting any data to the database, using (Fluent)NHibernate, that the operations are executed inside a transaction. Is there anyway of checking that a transaction is active via an interceptor? Or any other eventing mechanism? More specifically, I'm using the System.Transaction.TransactionScope for tr...