nhibernate

NHibernate many-to-one fetching same item many times

In my model I have Games. Each Game has an Event associated with it, which is mapped as a many-to-one association. When I query for Games, within event with given EventId (different than its DB-PrimaryKey-id) NHibernate issues the following query for each and every Game: NHibernate: SELECT event0_.Id as Id8_0_, event0_.EventId as Event...

How to query for most commonly used many-to-one in nhibernate

I have the following issue in the project I am working on. Each transaction in the system is assigned to a given user. So there is a many to one relationship between transactions and users, like so: public class User { public int ID { get; private set; } public string FirstName { get; set; } .... } public class Transactio...

NHibernate paging and Binding to Gridview

Hi. I have a Gridview, which is bound to an IList. I'd like to have paging " the safer way" (only fetching the Items I Need), so I created a metod on my repository like this public Ilist<Item> GetItems(int from, int number){ ... } The thing is that wheen I bind it, it only shows me the n items, and doesn't show the paging controls. I ...

Using Enterprise Library logging application block in NHibernate

Hi all: We are trying to integrate NHibernate as our OR/M, however, we are currently using Enterprise Library's logging application block. I know that NHibernate uses log4net to log. Does anyone have any example on how to use Enterprise Library to log NHibernate related logs? Thanks ...

Nhibernate and MS Access

Can NHibernate be used as ORM tool for MS Access? We are using Nhibernate to access Sql Server, so wondering if it can be reused. If it can be used how has the experience been? ...

Fluent Nhibernate and pluggable inheritance

Is there any way to define/expand inheritence without changing base table mapping with fluent nhibernate? For example with Castle.ActiveRecord (based on nhibernate) you can define inheritance like this: [ActiveRecord("entity"), JoinedBase] public class Entity : ActiveRecordBase { [PrimaryKey] public int Id{get;set;} } [ActiveR...

Nesting transaction scopes for integration tests using Rhino Commons UnitOfWork

I'm trying to set up a integration test class that wraps each test in a transaction. This way I can rollback the transaction after each test instead of resetting the DB before each test. I also want to be able to use transactions in the integration tests themselves. I am using NHibernate and the Rhino Commons UnitOfWork for the the pr...

NHibernate N+1 select : architectural solution ?

Considering the following "database" : Post -> User The entities : class User { public virtual string Name { get; set; } public virtual IList<Post> Posts { get; set; } } class Post { public virtual string Title { get; set; } public virtual User Author { get; set; } } And the following service Layer: class UserServ...

ISet Vs IList

In most of the NHiberate examples they use an ISET over an IList. I am aware of the basic differences between the two ie a set is unique. However, I am unsure why they use an ISet over an IList when doing lazy loading. What advantage does (Iesi.Collections.Generic)ISet have over IList? Particularity when lazy loading. ...

Fluent NHibernate, working with interfaces

I just switched to Fluent NHibernate and I've encountered an issue and did not find any information about it. Here's the case : public class Field : DomainObject, IField { public Field() { } public virtual string Name { get; set; } public virtual string ContactPerson { get; set; } public virtual bool Private ...

Mapping to an Enum bit flag in Nhibernate

Take the following Enum Flag [Flags] enum Permssions { CanComment = 1, CanEdit = 2, CanDelete = 4, CanRemoveUsers = 8, All = CanComment | CanEdit | CanDelete | CanRemoveUsers } In NHibernate I have mapped to a enum before using: <property type="n.Permssions, n.Permssions" name="Permssions" column="Permssions"></proper...

Question about Repositories and their Save methods for domain objects

I have a somewhat ridiculous question regarding DDD, Repository Patterns and ORM. In this example, I have 3 classes: Address, Company and Person. A Person is a member of a Company and has an Address. A Company also has an Address. These classes reflect a database model. I removed any dependencies of my Models, so they are not tied to a...

[NHibernate] Map unknown amount of columns to Dictionary

I have a legacy system that dynamically augments a table with additional columns when needed. Now I would like to access said table via C#/NHibernate. There is no way to change the behaviour of the legacy system and I dynamically need to work with the data in the additional columns. Therefore dynamic-component mapping is not an option si...

bidirectional one-to-many entity assosiation

If I have two objects, say ProductOrder and Product, I want both to be able to contain multiple references to the other, e.g. A Product can be referenced by multiple Orders A ProductOrder can contain multiple Products. I've attempted to do it as such... <set name="Products" inverse ="true" cascade="save-update"> <key column="Ord...

NHibernate's automatic (dirty checking) update behaviour - turning it off

I've just discovered that if I get an object from an NHibernate session and change a property on object, NHibernate will automatically update the object on commit without me calling Session.Update(myObj)! I can see how this could be helpful, but as default behaviour it seems crazy! Update: I now understand persistence ignorance, so thi...

How do I return a limited set of columns in a Castle ActiveRecord query?

and have it map to a strongly typed object? Suppose I have a entity Blog with Id,Name,Posted,IsUglyFace,YerMom but I just only want/need Name and Posted columns. I tried to do something like: IList blogs = repository.SimpleQuery("select Name, Posted from Blog"); This dumps out a ton more SQL and gives back an error, could not map to...

NHibernate - Is it OK to use an abstract base to provide functionality instead of an interface?

I'm fairly new to NHibernate and have run into a strange inheritance chaining issue with my repository classes. I've been using Gabriel Schenker's FAQ as a reference, and following his examples I've been creating interfaces to define contracts for DAO operations in "repository" classes. The data schema I'm working with is rather extens...

Using Interceptors with NHibernate, Spring.NET, Open Session In View

I'm trying to implement a simple interceptor that will automatically apply a CreateDate/UpdateDate values when an object is created or updated. I've scoured the documentation and forums at NHibernate, and I'm left wondering if there is an open bug with Spring.NET/Open Session in View. Looking at this forum thread, it appears that even ...

NHibernate - Force esacping on Table Names

Are there any good examples of how to use this (NHibernate.Criterion.IdentifierEqExpression) online? I couldn't find any. I'm a little confused about what you are supposed to pass into the constructor. I pass in an int32 of 1 and I keep thinking my test should basically do a "where id = 1" type of query and instead it blows up with "wh...

NHibernate Session.Evict()

I don't have access to code here in front of me so I was just wondering if someone could help me out with Session.Evict(). Say I have a Person object with a child collection of Addresses. I populate the Person object from a session and lazy load the Addresses collection. I then call Session.Evict(personObject) to detach the Person objec...