nhibernate

Bounding an eagerly fetched collection

How can I eagerly fetch a collection, but just the N first items? Using this code works, but is there an 'official way' to achieve that? public Gallery GetById(int id) { var session = GetSession(); var criteria = session.CreateCriteria<Gallery>() .Add(Expression.Eq("Id", id)) .SetFetchMode("Pictures", FetchMod...

NHibernate: Multiple Entities, One Transaction - Multiple Repositories?

I'm developing a web service using NHibernate, WCF and Oracle 11g R1. The web service is pretty simple: it maps DTOs to POCOs and performs various CRUD operations on them based on the operation called. Each entity has its own set of CRUD methods - this is a temporary, but necessary for the time being. I'm looking for input on a good R...

Getting NHibernate to save or update using column other than the <id>

Hi, How do I get NHibernate to save or update using column other than the <id>? I've implemented an identity key column in a table but this is not what makes a row unique. I know that "composite-id" exists but I heard that that should only be used on legacy databases, where there is not much freedom to change it. Is there any other w...

NHibernate CallSessionContext vs ThreadStaticSessionContext

Is someone able to explain NHibernate's CallSessionContext, and contrast it to ThreadStaticSessionContext. The best explaination I have been able to find, has been from the NHibernate documentation : NHibernate.Context.CallSessionContext- current sessions are tracked by CallContext. You are responsible to bind and unbind an ...

GUID in databases other than SQL Server

Question: I'm planning the database for one of my programs at the moment. I intend to use ASP.NET MVC for the user backend, the database being on Linux and/or on Windows. Now, even if I would only make it for windows, I had to take into account, that different customers use different database systems. Now, I figured I use nHibernate, t...

Fuent NHIbernate two mappings on the same table, no discriminator

Hi all, I have a table that references many items. In the general view, I don't want to load all these references, for obvious performance reasons, but in the global view, I would like to load the same table, with all the references. I tried making two classes mapped on the same table, but it loads the two classes when loading the table...

LINQ to NHibernate: selecting entity which has a specific entity in a one to many association

I would like to make this query: Session.Linq<User>().Where(u => u.Payments.Count(p => p.Date != null) > 0); In plain English I want to get all the users that has at least one payment with the date specified. When I run the sample code I get a System.ArgumentException with the message: System.ArgumentException : Could not find a ...

What is the business of Session.Clear() in NHibernate?

What does Session.Clear() do in NHibernate? I mean, what is the meaning of Clear in session? ...

How to visualize NHibernate hbm.xml files

Are there any tools or clever methods for me to I visualize the contents of NHibernation hbm.xml files? I would like to load hbm files into a designer and see them as entities with relations ...

Using nHibernate to retrieve Database Schema

Is it possible to generate a schema of a database from nHibernate, where I have provided nHibernate with the configuration to the database but I have not written any mappings. I wish to get the Database MetaData/Schema programmatically. I am using an Oracle Database. I have tried two approaches: Approach one: public DatabaseMe...

NHibernate always does an update on the bag items of one-to-many

Hi, I was just wondering if it was normal for NHibernate to always update the item that are on the "many" side of a one-to-many mapping i.e. the items in the bag, even when there was no change. I have this: <class name="PrimaryClass" table="PrimaryTable" lazy="false"> <id name="Id" column="id"> <generator class="assigned" /...

Mapping multiple discriminator values to single default class in NHibernate

I have an existing RoleType table with data. I am trying to map this table in NHibernate using Table per class hierarchy: <class name="IRoleType" table="RoleType"> <id name="Id" column="RoleID"> <generator class="native" /> </id> <discriminator column="RoleID" /> <property name="Description" column="Description" /> ...

NHibernate SQLite on Mono concurrency problem: Database file is locked

I have an application I'm porting from MSSQL and .NET to SQLite and Mono. I'm using NHibernate, FluentNHibernate, NHibernateLINQ and SQLite. When I test the application with only one person connected everything works OK, but the moment somebody else starts using the app it breaks and throws an SQLite Exception saying "Database File is ...

Invariant names for different ADO.NET providers

For a proposed change in NHibernate drivers to make it easier to build and deploy NHibernate-based solutions (see this thread) we need to collect the invariant provider names of the following RDBMS: Adaptive Server Anywhere DB2 Firebird Ingres MySQL Oracle SQLite SQL CE Sybase You don't need to know all of them to answer this questio...

NHibernate and SQLite: will an IgnoreCase() query be an indexed lookup or not?

The Foo column is defined as "Foo TEXT unique". Will an Eq().IgnoreCase() query use the index or will it perform a complete column scan? The query: string foo = "foo"; IList<T> list = session.CreateCriteria(typeof(T)). Add(Expression.Eq("Foo", foo).IgnoreCase()).List<T>(); ...

Castle ActiveRecord and AfterLoad event

Castle ActiveRecord has BeforeLoad event but I need AfterLoad event too. I know it's possible to use NHibernate's PostLoad event. But how can I do this? ...

Fluent NHibernate Mapping Error

I am getting the following error using Fluent: 12:16:47,879 ERROR [ 7] Configuration [(null)]- An association from the table Address refers to an unmapped class: System.Int32 NHibernate.MappingException: An association from the table Address refers to an unmapped class: System.Int32 public class Address { p...

How to handle exception in Flush phase?

Hi, how can I handle exception that is thrown in NHibernate method Flush? I have a action for deleting objects. It loads the objects from repository using posted ids and calls repository.Delete(obj). Leaving aside that my mapping in NHibernate is not complete and the delete results in "The DELETE statement conflicted with REFERENCE cons...

ActiveRecord/NHibernate DateTime problem

I'm using ActiveRecord/NHibernate for ORM mapping in my project with PostgreSQL 8.4. I have following issue For class mapping [ActiveRecord(Schema = "public", Table = "test_bean")] public class TestBean { [PrimaryKey(SequenceName = "test_bean_id_seq", Generator = PrimaryKeyType.Sequence)] public int ID { get; set; } [Castle.A...

NHibernate list/detail views using different sessions, but changing same object

Hello, My application consists of two views, list and detail. Basically when user double-clicks a row from a list, I pass selected item object to detail view. Every instance of view has it's own NHibernate session. When user modifies object properties, my list view needs to reflect changes, to do this I implemented INotifyPropertyCha...