nhibernate

How to model this situation in ORM (NHibernate)?

I've always taken a data centric approach to web apps, and so the paradigm change involved when taking a pure OO approach using ORMs is still not completely natural to me, and evey now and then something ostensibly simple is not obvious. Can someone please point me into the right direction of how to correctly model this situation in an ...

NHibernate include/exclude all

I'm building a complex security mechanism to filter access to objects depending on various rights. As part of this I want to have an initial OR in my query that excludes all possible results from the query before the permissions allow access to certain subsets. In SQL it would look like this: select * from Table where (1 = 0) ...

When should one avoid using NHibernate's lazy-loading feature?

Most of what I hear about NHibernate's lazy-loading, is that it's better to use it, than not to use it. It seems like it just makes sense to minimize database access, in an effort to reduce bottlenecks. But few things come without trade-offs, certainly it slightly limits design by forcing you to have virtual properties. But I've also ...

Comparing 2 NHibernate loaded object problem ...

Hello guys... I have a class Client like that: public class Client { public Person Pers { get; set; } } And I have 2 Person´s child class : public class PersonType1 : Person {...} public class PersonType2 : Person {...} So, my Client could be PersonType1 or PersonType2... I load 2 Client using NHibernate... And after that, I´...

Is it possible to suppress the Update after Insert in NHibernate?

I've been thrown into researching a database performance issue with a new application using NHibernate. I noticed that on some tables NH does an insert of a row followed by an update of the same row with exactly the same data. What I have gathered so far is that updates after inserts are done on tables that have many-to-one relationships...

Using MyGeneration with Fluent NHibernate

Hi All, I found a fantastic template for NHibernate code generation using MyGeneration here, http://vucetica.blogspot.com/2009/01/nhibernate-template-for-mygeneration.html This creates XML mapping files with the extension hbm.xml. I was wonder if anybody knows of templates which support fluent NHibernate which defines the mapping usi...

NHibernate handling mutliple resultsets from a sp call

I'm using a stored procedure to handle search on my site, it includes full text searching, relevance and paging. I also wanted it to return the total number of results that would have been returned, had paging not being there. So I've now got my SP returning 2 select statements, the search and just SELECT @totalResults. Is there any way...

Domain Objects Causing NHibernate Errors

Hi All, I have a domain object that has been auto generated for me by MyGeneration. This is generated using an NHbernate template. This is part of the object - I have removed most of it, [Serializable] public class Purchase : INotifyPropertyChanged { protected int id; public event PropertyChangedEventHandler PropertyChanged; ...

NHibernate One-to-One to Many-to-One mapping and wrong SQL

Hey, I need a mapping which maps Point to Question and vice versa (one to one). Point can be created only with association to existing Question, while Question can be stand alone and have Point equal to null. Also it is prefered that there is foreign key in Point table, not in Question table (though I'd be glad if otherwise solution will...

NHibernate Mapping Question - Bizarre scenario

I have an interesting scenario where I have a given table that maps to an entity. However, there is another version of the table which gets populated as part of a nightly process and has the exact same columns as the first table. Without getting into too many details, the second table is a "working" table with a small subset of records. ...

NHibernate Search with inheritance ...

Hello guys... I have a Client class like that: public class Client { public Person Pers { get; set; } } And I have 2 Person´s child class : public class PersonType1 : Person { protected string att1; protected string att2; } public class PersonType2 : Person { protected string att3; protected string att4; } pu...

How to fluent-map this (using fluent nhibernate)?

I have two tables in my database "Styles" and "BannedStyles". They have a reference via the ItemNo. Now styles can be banned per store. So if style x is banned at store Y then its very possible that its not banned at store Z or vice verse. What is the best way now to map this to a single entity? Should I be mapping this to a single entit...

cascade delete multiple levels with nhibernate?

I have a hierarchy of tables 3 levels deep (QualificaionType has many QualificationGroups, which have many Qualifications) mapped like this: // QualificationType HasMany(x => x.QualificationGroups) .Inverse() .KeyColumns.Add("QualificationGroupId") .AsBag() .Cascade.AllDeleteOrphan() .Access.CamelCaseField(Prefix.Und...

Problems with Castle DynamicProxy2 on .Net 3.5 SP1 on Win2003 Server

I've an mvc + nh asp.net application. On my dev machine (win 7 Ent) all works fine, if deployed on a Win 2k3 (tried 2 different vm and one phisical machine) I got the following error.. anyone can help? Cannot explain this issue (tried the same build, so i think it'a machine configuration issue).. Derived method 'set_ID' in type 'Custom...

Fluent NHibernate table per class hierarchy multiple tables mapping problem

Hello! I've got a problem with fluent nhibernate table per class hierarchy mapping. I've got 2 domain objects, container (baseclass) and album (subclass). Album only contains a constructor. Container dervies from EntityWithTypedId from Sharp Architect. EntityWithTypedId provides the key of type Guid (the name is ContainerId). public cl...

NHibernate.Linq LIKE

How can I produce this query using NHibernate.Linq? WHERE this_.Name LIKE @p0; @p0 = 'test' // Notice NO % wild card Note, this is not Linq To Sql or Entity Framework. This is NHibernate. Edit: Here is the desired query using ICriteria: criteria.Add(Expression.Like("Name", "test")); return criteria.List<Theater>(); ...

In NHibernate, my check if entity is dirty fails.

Background Similar to this question, I need to determine if an entity in my NHibernate application is dirty or not. There is a "IsDirty" method on ISession, but I want to check a specific entity, not the whole session. This post on NHForge describes a method of checking an entity by fetching its database state and comparing it to the ...

How do you automap List<float> or float[] with Fluent NHibernate?

Having successfully gotten a sample program working, I'm now starting to do Real Work with Fluent NHibernate - trying to use Automapping on my project's class heirarchy. It's a scientific instrumentation application, and the classes I'm mapping have several properties that are arrays of floats e.g. private float[] _rawY; ...

Is NHibernate still in active development for .NET

I heard somewhere that NHibernate for .NET will stop development because microsoft developed the enity framework. Is this true? ...

NHibernate Many-to-Once Cascade

Hi, I have created the mapping shown below between Invoice and InvoiceDetail. When trying to update an Invoice, I notice an update statement for User as well. Why should “User” be updated when we have set cascade ="none"? <class name="Invoice" table="invoice" lazy="false"> <id name="InvoiceID" column="InvoiceID" type="int"> ...