nhibernate

What is your session management strategy for NHibernate in desktop applications?

I find it much more difficult to manage your session in a desktop application, because you cannot take advantage of such a clear bondary like HttpContext. So how do you manage your session lifetime to take advantage of lazy loading but without having one session open for the entire application? ...

Lightweight alternatives to NHibernate

NHibernate is not really a good fit for our environment due to all the dependencies. (Castle, log4net etc.) Is there a good lightweight alternative? Support for simple file based databases such as Access/SQLite/VistaDB is essential. Ideally, something contained in a single assembly that only references .NET assemblies. If it only requ...

Multi tenant architecture and NHibernate

Could anyone explain me finally what is the best strategy to implement transparent and fluent support of multi-tenant functionality in NHibernate powered domain model? Im looking for the way, how to keep the domain logic as isolated as possible from the multi-tenant stuff like filtering by TenantID etc ...

Are properties accessed by fields still lazy-loaded?

I'm using the field.camelcase in my mapping files to setting things like collections, dependant entities, etc. and exposing the collections as readonly arrays. I know the access strategy does not affect the lazy loading, I just want confirm that this will still be cached: private ISet<AttributeValue> attributes; public virtual Attribu...

NHibernate, auditing and computed column values

How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties? E.g. every table contains audit columns like CreatedBy, CreatedDate, UpdatedBy, UpdatedDate. But I dont want to add these poperties to the domain classes. I want to keep domain modedl Per...

.Net Assembly Hell

I am Trying to develop a .Net Web Project using NHibernate and Spring.net. But I'm stuck. Spring.net seems to depend on different versions of the NHibernate assemblies (maybe it needs 1.2.1.4000 and my NHibernate version is 1.2.0.4000). I solved some problems with the "bindingRedirect" TAG, but now even that stopped working. My Questi...

Fluent NHibernate Many-to-Many

I am using Fluent NHibernate and having some issues getting a many to many relationship setup with one of my classes. It's probably a stupid mistake but I've been stuck for a little bit trying to get it working. Anyways, I have a couple classes that have Many-Many relationships. public class Person { public Person() { G...

Strict vs NonStrict NHibernate cache concurrency strategies

This question is about the difference between ReadWrite and NonStrictReadWrite cache concurrency strategies for NHibernate's second level cache. As I understand it, the difference between these two strategies is relevant when you have a distributed replicated cache - nonstrict won't guarantee that one cache has the exact same value as a...

User Defined Fields with NHibernate

I need to add a user defined fields feature to an asp.net c# application that uses NHibernate. The user must be able to add and remove fields from several objects in the system "on the fly", preferably without any system downtime. One important constraint is that the database schema can't be changed by the user - that is, I can add wha...

How can I generate "migration" DDL from NHibernate mapping files?

Hello. I'm using NHibernate 2 and PostgreSQL in my project. SchemaExport class does a great job generating DDL scheme for database, but it's great until the first application. Is there any way to generate "migration" DLL (batch of "ALTER TABLE"'s instead of DROP/CREATE pair) using NHibernate mapping files? ...

How do I select the Count(*) of an nHibernate Subquery's results

I need to do the following for the purposes of paging a query in nHibernate: Select count(*) from (Select e.ID,e.Name from Object as e where...) I have tried the following, select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...) and I get an nHibernate Exception saying I cannot convert Object to int32. Any...

What are best practices to implement security when using NHibernate?

Traditionalist argue that stored procedures provide better security than if you use a Object Relational Mapping (ORM) framework such as NHibernate. To counter that argument what are some approaches that can be used with NHibernate to ensure that proper security is in place (for example, preventing sql injection, etc.)? (Please provide...

How do I totally disable caching in nHibernate?

How do I totally disable caching in nHibernate? ...

How do you deal with concurrency in NHibernate?

How do you support optimistic / pessimistic concurrency using NHibernate? ...

NHibernate transaction and race condition

I've got an ASP.NET app using NHibernate to transactionally update a few tables upon a user action. There is a date range involved whereby only one entry to a table 'Booking' can be made such that exclusive dates are specified. My problem is how to prevent a race condition whereby two user actions occur almost simultaneously and cause m...

NHibernate nvarchar/ntext truncation problem

I'm using nhibernate to store some user settings for an app in a SQL Server Compact Edition table. This is an excerpt the mapping file: <property name="Name" type="string" /> <property name="Value" type="string" /> Name is a regular string/nvarchar(50), and Value is set as ntext in the DB I'm trying to write a large amount of xml to...

Auto-updating Bags in NHibernate.

I use ASP.Net with NHibernate accessing a Pgsql database. For some of our Objects, we use NHibernate bags, which map to List objects in our application. Sometimes we have issues with needing to refresh the objects through NHibernate when we update anything to do with the lists in the database. <bag name="Objects" inverse="true" lazy="...

Spring.net + Nhibernate Integration Tests Pass When They Should Not

I'm using Spring.net with NHiberante (HibernateTemplate) to implement my DAO's. I also have some integration tests, that extend from 'AbstractTransactionalDbProviderSpringContextTests '. DI is working fine, and all test pass BUT sometimes they pass even when they shouldn't. For example if my hbm.xml files have an error like this: <...

How do I view the SQL that is generated by nHibernate?

How do I view the SQL that is generated by nHibernate? version 1.2 ...

C# + Castle ActiveRecord: HasAndBelongsToMany and collections

Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like FindAllPostByTags(IList<Tag> tags) that returns all Posts that have all (not just some of) the Tags in the parameter. Any way I could ac...