nhibernate

Tags mapping in NHiberbate

When I'm asking this question on stackoverflow, I can add tags to it. So, in DDD, I would have a class Question that somehow has tags. One way to model it would be with a List of tags, since a tag is not really an entity (or is it?). public class Question { // ... public List<string> Tags; } In the database, however, I would ...

NHibernate Configuration.AddDocument is slow

Hi all, i'm testing fluent-nhibernate in a small project. I have near 10 classes and when I call BuildSessionFactory method I get a slow response of about 4500ms (too much for a project that runs in about 40ms) I have identified that the longest method call is Configuration.AddDocument(xxx) in the NHibernate assembly. I don't set use_r...

Empty NHibernate log file with log4net

I'm trying to get logging enabled on my application using Fluent NHibernate and log4net. I have tried the things described here, here, here and here. The log file is getting created, but nothing is getting written to it. The other log files for this and other applications all seam to be working OK, so I'm assuming the issue is something ...

FluentNHibernate joined-subclass

What is the current method of implementing the joined-subclass structure with FluentNHibernate? By "current", I mean by not using deprecated methods such as JoinedSubClass or AddPart. Thanks! ...

Linq to nhibernate - Having where clause problems

I am using linq-to-nhibernate with the following query: ISession session = GetSession(); var query = from storeZoneStyles in session.Linq<StoreZoneStyle>() from storeZones in session.Linq<StoreZone>() where storeZoneStyles.StoreZoneId == storeZones.StoreZoneId && storeZones.StoreCode == storeCode select storeZoneStyles; ...

NHibernate - Why is connection needed to build factory if connection can be passed to session constructor?

I'm new to NHibernate and am attempting to use it to connect to DB2. After trial and error and research, and more trial and error and research, I've finally come down to an error to which I cannot find an answer. The error message reads: "The user must provide an ADO.NET connection - NHibernate is not creating it." This error is not ve...

How do you determine the recommended ADO.NET Batch Size in the Real World?

NOTE: I'm not looking for the answer from MSDN. How have you gone about determining the proper ADO.NET batch size value for your given database / application? What factors led to your decision and what experience can you share? Using Fluent NHibernate, I'm currently using something like: var sessionFactory = Fluently.Configure().Data...

NHibernate many-to-many delete causing foreign key violation

I'm having a problem with a pretty simple setup in NHibernate. (I'm using Fluent Nhibernate) I have two objects as follows, setup with a bi-directional many-to-many mapping. Project -- Categories (IList) Category -- Projects (IList) -- Inverse = True This models as expected in the db. If I try to delete a project NHibernate perfo...

NHibernate - use factory instead of constructor

I'm quite new with NHibernate, so I'd like to know if this is possible with NHibernate. I have a simple type public class TestInfo { public int Id { get; set; } public string SomeProperty1 { get; set; } public string SomeProperty2 { get; set; } public string SomeProperty3 { get; set; } } and I'd like to persist the...

What should I return from an NHibernate Event Listener?

public class MyUpdateListener : IPreUpdateListener { public bool OnPreUpdate(PreUpdateEvent @event) { // What do I return from this method - true or false? } } ...

NHibernate Inheritance - Discriminator-Value

Is it possible to have a discriminator that works like this with NHibernate? If the value equals String.Empty --> Class1 Else --> Class2 I already have a string column for CultureName and I would like to use it as a discriminator. I don't want to add an extra boolean column. If the CultureName is String.Empty then I would like to one c...

NHibernate named query and 2nd level cache

Hi all, I have the following mapping <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Domain.Core" namespace="Domain.Core"> <class name="Industry" table="INDUSTRY"> <cache usage="read-write" region="IndustryCache" include="all"/> <id name="Id" type="In...

DDD Repositories pattern with NHibernate

Hi Im confused. This is a blog entry of Ayende Rahien Repository is the new singleton. I believe that a repository should only do CRUD operations and not addtional queries otherwise youll end up with methods like these on your repository. FindCustomer(id) FindCustomerWithAddresses(id) FindCustomerWith.. So my question is, where(in ...

NHibernate query baseclass without left joins to derived classes

Hi I have two c# classes one of which inherits from the other. Im trying to use NHibernate to map these classes such that I can query both as efficiently as possible. The base class is not abstract and needs to be able to be queried in its own right. The base class looks somthing like this. public class Cat { public int Id { get; se...

NHibernate many to many and ISession.Close()

I am using NHibernate for my project. i am quite a beginner at working on NHibernate. I use many-to-many relation mapping "users" and "roles". Here is the code to get the user: public User GetUser(int userId){ using(ISessuib session = new SessionManager().GetSession()) { return session.Get<User>(userId); } } public void Laz...

NHibernate Error - Save the Transient Instance Before Flushing

Hello, I had successfully written a system that contained an order with child order lines, using cascade updates from the order to save the order lines. In the next iteration I want to associate the order lines with a despatch class. This seemed quite straight forward - add a nullable DespatchID column to the order line table as a for...

NHibernate System.IndexOutOfRangeException

I've got a really simple class that is giving a strange error. The class only has 1 property and the query is really simple. The stranglest part is that this seems to happen randomly. After getting this error usually refreshing the page makes it go a way and the application doesn't get the errror again. Could this be a problem with the ...

NHibernate ManyToMany relationship - using AuditInterceptor - object references an unsaved transient instance - save the transient instance before flushing

The domain model the DomainObject's audit fields are populated using an AuditInterceptor. DomainObject Id EstablishDate EstablishId UpdateDate UpdateId Message : DomainObject Description MessageDistributions Distribution : DomainObject BeginEffective EndEffective MessageDistributions MessageDistribution...

Should custom server control access data or be fully bound from client?

The question is whether it's better to encapsulate general data code within a server control or bind the data to the control from the client? The control will be utilized by various different applications and the data is generally only for the control. So the question is, rather than duplicate the code to bind the control in every clie...

Basic clarifications about NHibernate

Given that I'm very good with SQL and c#, Should I learn another layer on top like NHibernate ? Is NHibernate just a library (that stores in a Database)? Or it's a service? Should I use NHibernate or ADO.NET Entity Framework? If you think I should learn/use an ORM, give me your top reason. ...