nhibernate

RIA Services does not support entities that are decorated by NHibernate mapping attributes?

...

How to retrieve unique entities through NHibernate Criteria API?

Hi! My entities look something like that (simplified): public class Person { public Guid Id { get; set; } public string Name { get; set; } public IList<Department> Departments { get; set; } } public class Department { public Guid Id { get; set; } public string Name { get; set; } } I'm querying the database throu...

Is anyone using Velocity for NHibernate second level caching in production

Is anyone using Microsoft Velocity for NHibernate second level caching? What are your experiences? ...

NHibernate.Caches.Velocity change cache name

We have noticed that Velocity cache name in NHibernate.Caches.Velocity.VelocityClient is hardcoded to "nhibernate" private const string CacheName = "nhibernate"; . . . cache = cacheCluster.GetCache(CacheName); Is there a patch which enables changing cache name from configuration file. It would be good that our apps use caches with dif...

PersistenceSpecification and Enums

How does one test enum type properties with PersistenceSpecification. I have it mapped like this Map(x => x.AccountStatus).Column("Status").CustomSqlType("int").Not.Nullable(); and I check it like this spec.CheckProperty(o => o.AccountStatus, UserStatus.Disabled) but it fails with this message NHibernate.HibernateException: ...

Call method on class with NHibernate Criteria

Say i have a object like this public class Student{ public IList<Coursework> Courseworks{get;set;} public string Name{get;set;} public int Age{get;set;} public bool HasCompletedCoursework(int courseyear, string moduleName) { return Courseworks.Any(x => x.Courseyear == courseyear && x.ModuleName == moduleNam...

In Fluent NHibernate how do I specify a dictionary mapping type size?

How can I specify the size of the type used in the following Dictionary mapping: HasMany(x => x.WidgetSettings) .AsMap<string>(idx => idx.Column("SettingKey"), elem => elem.Column("SettingValue")) .Not.LazyLoad() .Table("WidgetSettings"); The mapping defau...

Lazy load a collection of data from a service, not the database

My domain objects support custom fields that are stored in such a way that requires metadata and logic to be applied before their values can be stored and retrieved. I already have a Custom Field Repository that handles the persistence of custom fields, and I don't want to try to recreate that logic in NHibernate mappings. I would ho...

In Fluent NHibernate how do you combine automapped types with non-automapped types?

Right now, I'm switching my project over from the classic fluent nhibernate style of manually defining a ClassMap for each domain entity, to having the auto-mapper auto-generate the mappings for me. But I'd like to keep using the classes I've already mapped in the classic style, until I can tweak the automappings to match the old classi...

How to provide Prompt Lists in an NHibernate WinForms application

Background WinForms application using NHibernate. Application is in MDI style and each MDI child form opens a new NHibernate session at Load which remains open for the life of the form. Question My application is basically an "order management" or "purchasing" system. One particular form uses a lot of "lookup" lists. Like a list o...

How to handle NHibernate LINQ empty result set?

I want to retrieve list of roles for a logged in user. Following is a code segment that reads user roles from the database. ISession session = NHibernateHelper.GetCurrentSession(); var data = from s in session.Linq<ApplicationUserRole>() where s.AppUser.ID = 1 select s.Role.Name; ...

NHibernate many-to-many with non ID fields

Hi, I have a table A containing items with : - an identity key - a non-nullable custom hash (generated on my own) I have a table B containing documents with : - an identity key. I have a table C containing documents slots with : - an identity key - a foreign key to table B (document) - a nullable custom hash (so table A is implicitly ...

Paging in NHibernate

Lets say I have a domain model with a class called Blog that has a property called BlogEntries (that contains objects of type BlogEntry). If I have a database model with two tables "Blog" and "BlogEntry", it's not impossible that I have 1000 blog entries for a blog. If I were to show the blog on a web site, I would only want to display m...

nhibernate + migrations workflow

Hi I'm looking to refine my workflow around NHibernate and a relatively frequently changing schema, and how best to deal with this - I would like the same solution to apply to production systems, so I think I need a migration engine rather than just Schema Update. What I want to know is how i can refine the workflow as far as possible s...

Nhibernate transaction exception

I am using Nhibernate in a session-per-request context. When I use session.Update and commit or rollback my transaction, I get an ObjectDisposedException. the stack trace for this exception is: at NHibernate.Transaction.AdoTransaction.CheckNotDisposed() at NHibernate.Transaction.AdoTransaction.Rollback() at MyService.update(MyI...

What are the problems associated with sending a Hibernate Proxy class to clients.

I have a POCO classes that I am using with NHibernate in a WCF service layer. And I am thinking about trying to send the NHibernate proxy classes down to a client. This is a client that I control. We handle record updates with a system wide reservation so there can only be one writable copy of this entity sent to a client at any given...

Fluent NHibernate mapping: one table, many classes

How would I go about mapping three classes to one table with fluent NHibernate. A "Type" column should indicate which class should be mapped. Is it even possble? Kristoffer ...

NHibernate Readonly Entities at Runtime

I would like to know if there is a way to make an instance of an entity immutable at runtime. I know that I can have readonly types, but I would like readonly instances of types at runtime. Reason being, that I want to use NH domain objects like a lightweight entity by modifying properties, but don't want those changes to persist when ...

NHibernate Validator with EntityMode.Map

I'm developing application with NHibernate EntityMode.Map so I have entities of IDictionary without cs domain model, database configures only with hbm files. It gives me lots of flexibility. I want to find out does NH.Validator support this EntityMode.Map too? If yes how to configure it properly, now I'm getting exceptions related to m...

NHibernate HQL Join Not Returning All Required Rows

Hi, I am modifying an existing HQL query which returns individual columns rather than an object graph but now I am not getting all rows that I need. Here a few facts about the current schema: An Estimate belongs to a Contract. The OwningDepartment property of a Contract can be null. The ParentBusinessStream property of a Department c...