nhibernate

SetCacheable throws IndexOutOfBoundsException

I have following query in NHibernate where the result is a list of DTO's, not entities: var result = query //.SetCacheable(true) .SetResultTransformer(new MyDTOTransformer()) .List<DTO>(); This works with SetCacheable in comment but it throws an IndexOutOfBoundsException when I set SetCa...

nhibernate multicriteria CTE subquery

I currently have a MultiCriteria query, which filters the results based on the ids being within a sub query Subqueries.PropertyIn("Id", detachedCriteria) The sub query is the same for all queries used in the multicriteria query. It seems a bit ugly looking at the sql that the sub query is repeated, in my current case 15 times. The r...

NHibernate Winforms Lookup - Combobox Binding

Hi, I'm using NHibernate 2 with WinFoms. I try to use a Combobox as a Lookup - Combobox. I bind it the normal way. But it doesn't work (error:invalid value). What can I do? ...

User's generated specifications

I want to let my users create specifications to be executed in a nhibernate.Linq query. Is it possible? I ask the user to write a query string (HQL I suppose) so it will be serializable and in a combobox the user can apply it to current results ...

How to generate hbm.xml file from FluentNHibernate

I'm trying to follow this tutorial but instead of generating the expected hbm.xml files with my mappings in it generates simple .cs class for my entities like for example: public class ProductMap : ClassMap<Product> But I already defined those myself in code. I'm after the .hbm.xml which I can use in standard NHibernate at this time. ...

nhibernate not pulling back the entire object

I have the following method that creates a view model. On my mvc app i called this on http get: "/Product.aspx/Edit/8024" and then on http post "/Product.aspx/Edit/8024" My issue is that when i called it on "post" i don't get the entire product class, ie it's missing generic list ie List<Category> categories Here is the method t...

Caching objects and stuff in NHibernate

I've written my own caching layer for my objects that come out of data access. My reasoning here is I'd like my data access layer to do just that -- data access. I don't really want it to worry about caching, and I'd only like to go in to that layer when I need to fetch data out of the database. Perhaps this is not the right way to think...

How to implement historical versioning?

We are in the early stages of building a large C# MVC2 app (we also employ Sharp architecture and Nhibernate as part of the ecosystem) on SQL 2008 R2, and one of the requirements is that all database row versions are accessible for a given period of history. We have toyed with the idea of a layout similar to: id (PK) recordId versionId...

Castle ActiveRecord FK as discriminator column

I have just started using castle active record and i am having some problems using a foreign key as the discriminator column. I get the error "Invalid index 2 for this SqlParameterCollection with Count=2." The tables i am using are:- TABLE MemberRoles [Id] [int] IDENTITY NOT NULL, [Name] [varchar] NOT NULL TABLE Members [Id] [int] IDE...

NHibernate data retrieve problem.

These codes are working well when saving data. But it is unable to retrieve data from b_TeacherDetail-table. For example: TeacherRepository tRep = new TeacherRepository(); Teacher t = tRep.Get(12); Here, t.TeacherDetail is null. But I know that there is an entry in the b_TeacherDetail-table for teacher-id 12. Why? My tables are: T...

Parent - Child relationships in NHibernate

I want to be able to create a parent object with children and let the parent handle the update, saves and deletes. My map classes. ParentMap Id(x => x.Id, "ID").GeneratedBy.Identity(); Map(x => x.Name); HasMany(x => x.Children) .KeyColumn("ParentID") .Inverse() ....

NHibernate mapping collection without foreign key

Hi all, I have a class called WorkingDays, this class requires a collection of dates that are the dates of bank holidays. In our database we have a table that contains these dates - I want nhibernate to get all those dates and populate the bankHolidays collection. The catch is however I do not have a table that represents the link in ...

How to get an object from the database with NHibernate?

I'm trying to get an object back from an NHibernate query. My method is as follows: public Site GetSiteByHost(string host) { var result = _session.CreateCriteria<Site>() .Add(SqlExpression.Like<Site>(g => g.URLName, host)); return result; } the problem is, result is a type of HNibernate.ICriteria. How can I get this...

Fluent NHibernate misplaced duplicate field

I think I'm misunderstanding something about how this works. This is my fluent mapping: public class FunctionInfoMap : ClassMap<FunctionInfo> { public FunctionInfoMap() { Id(x => x.Id); Map(x => x.Name); Map(x => x.Signature); Map(x => x.IsNative); Map(x => x.ClassId); References(x => x.Class, "ClassId"); HasMa...

How do I configure cache regions for syscache in nhibernate?

Hi, I tried to use a cache configuration like this post from a website: <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" requirePermission="false"/> <section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache"...

NHibernate -problem in saving models with parent child relationship

I am having a problem saving the Parent object which contains multiple children. The Model Classes are as follows: public class Driver { private IList<CitationEvent> _CitationEvents = new List<CitationEvent>(1); } public class CitationEvent { public virtual Driver Driver { get; set; } } XML Mapping in Driver.hbm.xml <bag name...

nhibernate, load-balancing, failover, and caching

We have a server that uses NHibernate, and we would like to load balance multiple instances of this server. Our database is big, ~100 GB. If we use a distributed second level cache like memcached or sharedcache, are there still potential data integrity issues? And, why doesn't the first level cache need to be distributed? Also, how ...

Something lighter than nHibernate

I want to develop a C# <-> Database application. I've considered using a ORM creating me classes for transparent access to whatever database I want to connect to. I found nHibernate. But this seems very heavy and complicated to configure. My question: Is something out there that is lighter than nHibernate? Thanks, Andre Edit: Love yo...

Castle ActiveRecord - sorting by custom sql expression

Hey, I'm using MonoRail ActiveRecord and have a query that returns businesses within a certain number of miles of a user. I was able to use Expression.Sql to do the distance calculation, however I now need to sort the results by the distance. How do I add a custom sql expression into criteria.AddOrder()? Here's the code: var criteria =...

fluent nhibernate table column type mapping

hi there, i've been working with fluent nhibernate for a couple of months and i think it's a very flexible tool (even if 'tool' is maybe incorrect term) :) i've to work on a new project and i'm still considering using fluent nhibernate solution to map my db on a repository layer. The matter is that, for some reason i really don't unders...