nhibernate

[nhibernate validator] how to validate custom properties?

I played around with nhibernate validator and got a nearly perfect solution. I can define a property to be validated and it's done on pre-save. But I have some cases where it's not working. Let's assume I have an object called person and via nhibernate I mapped the address(also an object) to be a property of person (in fact it's a lis...

nhibernate datacontext

on form i have two button cancel and save. when i modify the data in form after search and press save, its work fine and data saved. But when i press cancel and go to seach control its show the changed value (which i have cancel). My question is that how i can protect nhibernate to show only DB value not temperory content or cache? you ...

NHibernate, DevExpress Performance

Hi, everyone. I have problem with perfomance in my website. I am using NHibernate to retrieve my database tables and AspxGridView as component from DevExpress. After debug I found problem connecting with dual calling Page_Load event. What can I do?? May be devexpress gridview after initialize make ajax request to server and page life ...

nhibernate datacontext

on form i have two button cancel and save. when i modify the data in form after search and press save, its work fine and data saved. But when i press cancel and go to seach control its show the changed value (which i have cancel). My question is that how i can protect nhibernate to show only DB value not temperory content or cache? prob...

NHibernate: eager-reload transient object deep nested child properties

I want to keep an entity, being configured by the user on several pages, in Session. This entity is loaded with NHibernate, with some of its properties/collections lazy-loaded. Say: Session["order"] = new Order(productRepository.Get(id)) on some next page, get Session["order"] and now work with it but, at this time order is...

What is the HQL equivalent of this SQL

Trying to do a bit more complex query, and thought that HQL would be better for the job. Using nHibernate. SELECT * FROM [Group] g INNER JOIN [User2Group] ug on g.Id = ug.GroupId INNER JOIN [User] u ON u.Id = ug.UserId INNER JOIN Activity a on g.ActivityId = a.Id WHERE u.Id = ? AND a.Lineage LIKE '?%' I guess I could also just...

NHibernate / Localization / Lookup tables

I want to add localization support to my domain object. I have the following: class Person { int Id; City city; } class City { int Id; string Name; } All cities are saved in a lookup db table "Cities". I would like to have: Person p = PeopleService.GetPersonById(1); //Assert p.City.Name == 'London' if culture == 'en-us' I dont li...

Why does this Nhibernate query return an empty list?

Why wouldn't this query work it always returns a empty list (Mapping is ok and i m sure the database has the data !) any ideas ? var ids = //IList<int> of ids var result = _session.CreateCriteria(typeof (User)) .Add(Restrictions.InG("Id", ids)) .CreateCriteria("Posts") .AddOrder(Order.Asc("CreatedO...

What is the HQL equivalent of this SQL?

SELECT * FROM [Group] g INNER JOIN User2Group ug **on g.Id != ug.GroupId** INNER JOIN [Activity] a on a.Id = g.ActivityId WHERE g.UserId != 2 AND a.Lineage like '0,1,%' Group > 1-n > User2Group < n-1 < User m-n relationship Activity > 1-n > Group 1-n Trying to get all groups that a user has not already added to their account....

Parse a search string (into NHibernate Criterias )

I would like to implement an advanced search for my project. The search right now uses all the strings the user enters and makes one big disjunction with criteria API. This works fine, but now I would like to implement more features: AND, OR and brackets() I have got a hard time parsing the string - and building criterias from the stri...

Nhibernate NullReferenceException returning List of domain objects

Following is the code I am using. Seems pretty simple to me. But I get a NullReferenceException at the last line , the return statement. Here is the stack trace: FailedSystem.NullReferenceException: Object reference not set to an instance of an object. at NHibernate.Criterion.Junction.ToSqlString(ICriteria criteria, ICriteria...

Mapping my existing ID column using NHibernate that keeps identity incrementing

I'm learning NHibernate to learn a more robust ORM than linq to sql, but i'm struggling with some simple things. My first challenge is mapping this ID column using hbm.xml. CREATE TABLE [dbo].[Party]( [Id] [int] IDENTITY(1,1) NOT NULL CONSTRAINT [PK_Party] PRIMARY KEY CLUSTERED ( [Id] ASC ) WITH (PAD_INDEX = OFF, STATISTICS_NOREC...

Custom Converters for domain types using NHibernate

Hi, My domain model is using System.Net.Uri to represent URLs, and System.Drawing.Color to represent colors. In the db, uris are simply nvarchars and colours are web (hex) rgb values. Using NHibernate, is there some way to map between these values using some custom mapper? I don't need to query against these items, but it would be nic...

Nhibernate union load for legacy app

Hi! Our legacy app there is this interesting feature that Order master table is splitted into two tables Order_Master and Order_Master_History. In Order_Master table there are all today orders and Order_Master_History table will have all historical info. The new integration app I write would need to benefit on those two tables as unio...

FluentNHibernate mapping for Dictionary

What is the best way of mapping a simple Dictionary property using Fluent NHibernate? ...

Configuring NHibernate Validator on a Burrow ASP.net Application

I'm looking for the best way to configure NHibernate Validator on a classic ASP.net app that is using NHibernate Burrow to manage NH sessions. How do I get it to register the interecptors automatically? ...

NHibernate: sometimes I want one item, other times I want them all

I have a database schema that stores one "Page" with many "Revisions". Like a simple wiki. 90% of the time when I load a page, I am just interested in the latest revision. However, sometimes I want all revisions. With NHibernate I can map the Page to the Revisions, and tell it to lazy-load. However, when I access the latest revision, ...

fluent nhibernate r1.0 fluent mapping disable lazy load

how to disable lazy loading in fn r1.0? ...

NHibernate: using an existing public int field as record Id

I have an existing class that I'd like to persist as-is. class Foo { public int Id; ... } I have the following ClassMap: class FooMap : ClassMap<Foo> { Id(x => x.Id); ... } Building a session factory results in an invalid cast exception. My setup works if my entity class has the standard "public virtual int Id { get...

Castle ActiveRecord/NHibernate System.Data.Services dependency and Mono 2.4.2.3

Getting the following compilation error trying to port ASP.Net MVC application using Castle ActiveRecord to a mod_mono server. Is System.Data.Services not available with mono? If not, do I have to throw out version 2.0 of Castle ActiveRecord framework since it has this dependency, or is there an alternative? ** (/usr/lib/mono/2.0/gmcs...