nhibernate

NHibernate - Incorrect thinking? Subclassed Model based on Join

I have a simple model class (Part), which pulls from it's information from a single table (t_Part). I would like a subclass of this model called (ProducedPart), that would still utilize NHibernate's caching mechanisms, but would only be instances of (Part) that have a foreign key relationship in a table called "t_PartProduction". I do ...

NHibernate Joins Returns array of objects. Why?

I dont understand why NHibernate returns an object[] when a join is performed but Hibernate does not. For example. The mapping The query session.CreateQuery("From CameraMount m left join m.Presets").List(); This will return an object[] where I would expect it to return a CameraMount that has its set of Presets initialized. W...

NHibernate projection help

Hello there, Im having a problem creating a projection for my nhibernate detachedcriteria object. I have a class Spa which is linked to table Address. Address has a field called City which is a string. public class Spa : IAggregateRoot { [BelongsTo("AddressID", Cascade = CascadeEnum.All)] public Address Address { ge...

3 Level Batch Updates using NHibernate

Update: Batch updates are now working, but as I access children bags are re-read from db even though the enitites have be loaded. Using NH Profiler to watch is awesome. Unit Test: NHibernateSession.Current.Transaction.Begin(); var reservationEventIds = new List<int>() {123, 124, 125}; var repository = new Repository<Reserva...

Fluent NHibernate Automapping: Alter DateTime to Timestamp

Hello, I am getting (a little bit to) deep into automapping with the fluent interface of NHibernate. Very nice thing, but I ran into a little problem with DateTimes. I need to change the data format to timestamp, otherwise NHibernate truncates milliseconds. I found several sources of information, the best one was: AutoMapping Info 1 whe...

NHibernate ICriteria query with components and collections for advanced search

I'm building an advanced search form for my ASP.NET MVC app. I have a Customer object, with an Address Component: Fluent NHibernate mapping: public CustomerMap() { WithTable("Customers"); Id(x => x.Id) .WithUnsavedValue(0) .GeneratedBy.Identity(); Map(x => x.Name); Ma...

NHibernate session management in WCF application

I am building a WCF application, using NHibernate for the persistence layer. A lot of documentation thats out there is about using NHibernate with ASP.NET applications. But very little on the best ways to manage NHibernate Sessions in a WCF application. After reading up on Instance Management Techniques in WCF applications, I am going...

Using NHibernate to determine which fields have been updated (for validation purposes) before persisting

Prior to persisting updates to my business entities, I need to perform validation checks to determine which properties have been changed. For example, certain fields can only be updated when the "Status" property has a particular value. E.g. when an Order entity has a Status of finalized, only the notes (string) field can be updated. ...

NHibernate - CreateCriteria vs CreateAlias

Hi, Assuming the following scenario: class Project{ public Job Job; } class Job{ public Name; } Assuming I want to use the Criteria API to search for all projects whose Job has the name "sumthing". I could use the CreateAlias to create an alias for Job and use it to access Name, or I could create a new Criteria for the proper...

NHibernate Query that simulates SQL Replace Function

I have a phone number field that can have lots of different characters such as "-" "." "(" ")", etc. I want to search for a phone number but I want to exclude specific characters. I'm not sure how to simulate this functionality with NHibernate Criteria or HQL. ...

NHibernate multiple database providers

I have a WPF App that is run on the client. I have two different databases the app uses. One that is SQL Server 2008 for the application data and one that is Sql Server Compact for user settings stored on the client. I am using the app.config to configure NHibernate. I've seen a lot of articles using the "schema" attribute in the class m...

code generation tool for ORM mapping

There seems to be no end of code generation tools out there and would rather not have to go through each to see what is still maintained, easy to use, and provides customization. The code generation is for NHibernate mapping and subsequent creation of value objects or Data Transfer objects (DTO). It would be great if it could also gener...

Comparing hand-written ADO/Sprocs w/nHibernate

Hi, I am going back and forth between using nHibernate and hand written ado.net/stored procedures. I currently use codesmith with templates I wrote that spits out simple classes that map my database tables, and it wraps my stored procedures for my data layer, and a thin business logic layer that just calls my data layer and returns the...

paged data using a CTE, how would nHibernate handle this?

Hi, I use CTE to handle paging of data currently, can criteria queries handle CTE? ...

Fluent NHibernate with development/test/production databases?

I was wondering if anyone had developed an approach for using NHibernate / Fluent NHibernate with different databases depending on the application's configuration (similar to Rails' development, test, and production databases). I believe I could get something working by using methods with conditional attributes, but I would be intereste...

Retrieving object and child collection in NHibernate using Linq

Hi, I have a problem using Linq to NHibernate to load an object and eagerly load a child collection. The objects look like this: public class Order { public Guid Id {get; set; } public IList<OrderLine> OrderLines {get;set;} } public class OrderLine { public Guid Id {get;set;} public string Item {get;set;} } I am tryi...

What do they mean by persistence in nHibernate?

Hi, What does the term persistence mean when dealing with nHibernate? What exactly is persistent? ...

nhibernate and class design

Hi, Say I have a Employee class, and a Sales class. Now say I want to create a page that has a report, displaying all the sales information for a given Employee. When I return the collection, would I have to define a new class for the colllection returned? Because I don't want to return ALL the columns/properties for Employee & Sales...

nHibernate Validator custom IMessageInterpolator

Has anyone managed to get a custom IMessageInterpolator working to enable customisation of error messages. I have tried following the instructions on this web page but to no avail. http://codelog.climens.net/2009/03/04/nhibernate-validator-custom-messages/ Looking into the code the DefaultMessageInterpolator seems pretty baked into the ...

When is the configuration loaded with nHibernate?

I was reading that the initial load time for the configuration can be fairly long in nHibernate depending on the # of mapping tables, etc. Is this done once and stored in session or cache? Will it happen every time the ASP.NET process recycles? ...