nhibernate

nhibernate fluent repository pattern insert problem

I am trying to use Fluent NHibernate and the repository pattern. I would like my business layer to not be knowledgeable of the data persistence layer. Ideally I would pass in an initialized domain object to the insert method of the repository and all would be well. Where I run into problems is if the object being passed in has a child ...

Exposing entities via a nHibernate implementation RIA Services with querystring queries

I once read a blog post and cannot find it anymore. drat! It was about a guy who setup a wcf service (I guess RIA, but could have been something else) exposing the model via IQueryable to the querystring. Sou you could say http://host/articles/123/ratings and you'd get a list (soap or json) of serialized Rating entities (the properti...

Need help optimizing a NHibernate criteria query that uses Restrictions.In(..)

I'm trying to figure out if there's a way I can do the following strictly using Criteria and DetachedCriteria via a subquery or some other way that is more optimal. NameGuidDto is nothing more than a lightweight object that has string and Guid properties. public IList<NameGuidDto> GetByManager(Employee manager) { // First, grab all ...

common problem with Hibernate/NHibernate and child IDs

I'm asking both Hibernate and NHibernate groups because I'm thinking this may be a common issue seen on both. What does it usually mean when you call a saveOrUpdate on a child object and... 1) If it is an insert everything works fine. 2) If it is an update its wiping out the parent ID in the database. More info: problem is really occur...

How to achieve an eagerly loaded, filtered child collection with the NHibernate criteria API

Is it possible to use the criteria api to load a set of parent objects along with a filtered, eagerly loaded set of child objects? I'm trying to query a list of categories and at the same time load the categories products that start with the letter M. The query below gives me the results I want but the Products are not eagerly loaded, ...

Parameter cannot be null error after success save

I am getting the following nhibernate error when saving an entity (via: NHibernateSession.Save(entity);) despite it being persisted to the database fine "Value cannot be null.Parameter name: id" This is my hbm file <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="mydatabase.Doma...

Managing NHibernate ISession with Autofac

Does anyone have any tips or best practices regarding how Autofac can help manage the NHibernate ISession Instance (in the case of an ASP.NET MVC application)? ...

Get Nhibernate entity and complete it from a web service.

Hi every one. let's say that i have an order system. each "Order" references a "Customer" Object. when i fill the orders list in Data Access Layer, the customer object should be brought from a Customer Web Service "WCF". so i didn't map the Customer property in the Order mapping class, Id(o => o.OrderID).GeneratedBy.Identity(); ...

Series of abstract classes and NHibernate

Hello, and first off thanks for your time to look at this. For a research project I'm working on, I have a somewhat complex design (which I've been given) to persist to a database via NHibernate. Here's an example of the class hierarchy: TransitStrategy, TransportationCompany and TransportationLocation are all abstract classes. The...

Entity Framework 4 missing features?

I'm well aware that similair topics have been brought up before e.g. http://stackoverflow.com/questions/1639043/entity-framework-4-vs-nhibernate But instead of arguments like: NHibernate have been around longer and is more mature EF4 is drag n drop and not enterprisy EF4 and LinqToSql are ... I would like to see a more detailed lis...

NHibernate and reporting

I am building a website on top of nhibernate. Is there any efficient way to build reports? BY reports, I mean is there anyway to execute a complicated query that grabs random pieces of data? StoreProcedures? Hql? Can I get single, non mapped values from hql? ...

NHibernate Performance Optimization | Suggestions invited!!!

Hi, I’m facing an issue with NHibernate performance and can you please suggest me some optimizations? Below mentioned is a small summary of my application architecture I have a windows service which is listening to a messaging bus. On receiving a message the service creates an object out of which a property is the received xml snippet ...

How to retrieve row count of one-to-many relation while also including original entity?

Say I have two entities Foo and Bar where Foo has-many Bar's, class Foo { int ImportantNumber { get; set; } IEnumerable<Bar> Bars { get; set; } } class FooDTO { Foo Foo { get; set; } int BarCount { get; set; } } How can I efficiently sum up the number of Bars per Foo in a DTO using a single query, preferrably only with the Cr...

Nhibernate One-to-one mapping issue with child object insert error

Hi, i've being banging my head against the desk all day with the following Nhibernate problem. Each bank account has one (and only one) set of rates associated with it. The primary key of the bank account table, BankAccountID is also a foreign key and the primary key in the AccountRate table. public class BankAccount { public virtu...

When using a HiLo ID generation strategy, what types should be used to hold Ids?

I'm asking this from a c#/NHibnernate perspective, but it's generally applicable. The concern is that the HiLo strategy goes though id's pretty quickly, and for example a low record-count table (Such as Users) is sharing from the same set of id's as a high record-count table (Such as comments). So you can potentially get to high number...

NHibernate and State Pattern persistance - a good implementation?

Below is my implementation of the state pattern. In order to persist the State object to my database with NHibernate, I am assigning each state class an enum value. This is stored as a private field on the entity, and mapped to a integer field in my database table. I want to know whether this is a good implementation as I will be using ...

NHibernate mapping problem - Invalid object name 'Employee'

Hi, I am trying to configure NHibernate on my console application in which I am trying to map an Employee class to a table Employee. I am getting below exception which I have no clue: Class: class Employee { public int id; public string name; public Employee manager; public string SayHello() ...

SQLite database verification after nhibernate schema generation

What is the simplest most effective way to verify that your SQLite db is actually out there after using NHib's schema generation tool? Cheers, Berryl EDIT I am hoping there is something tied to the ISession (like the connection property) that can be tested; sometimes when running a series of tests it seems like a good session (IsOpen ...

NHibernate / ORM - Child Update over Web Service

What is the correct way to UPDATE a child object with NHibernate but not have to "awake" the parent object. Lets say you would like to try to avoid this because the parent object is large or expensive to initiate. Lets assume classes are called Author(parent) and Book(child). (still, trying to avoid instantiating Author) Book comes bac...

How to query flags stored as enum in NHibernate

How to do either a HQL or a Criteria search (the latter is preferred) involving an enum that is used as flags. In other words, I have a persisted enum property that stores some kind of flags. I want to query all the records that have one of these flags set. Using Eq won't work of course because that will only be true, if that is the only...