nhibernate

'table per subclass' or 'table per class hierarchy'

Hi, I am using FNHibernate and its default is 'table per subclass' for inheritance mapping. This seems to be the cleanest way to do things but it has its downsides too. My problem is that I have to seed the database with lots of tab separated data. I have tried to do this via repositories/services (i.e. via FNHibernate) but this is ver...

nhibernate fetch header data alone

I have a one-to-many relationship set up. But few scenarios I only need to bring the parent object (not the child collection). Is this possible using criteria queries ?? ...

NHibernate constructor injection

I have a domain type, MyDomainType, mapped to a db table using NHibernate. I'd like an instance of MyInjectedType to be injected into the constructor of MyDomainType when each instance is initialised by NHibernate, so that the injected type instance is ready and available for use within MyDomainType instances retrieved from the database....

Bizarre NHibernate exception: 'Uninitialized proxy passed to save().' caused by factory event configuration

There mere presence of a custom DefaultSaveEventListener subclass containing no overidden or extended behaviour is enough to trigger this bizarre exception for me when flushing or committing a transaction, using the following configuration Xml: <event type="save-update"> <listener class="MyNamespace.MyCustomSaveEventListener, MyAsse...

Object gets disconnected from nHibernate session after TryUpdateModel is called.

This works: public ActionResult Save(int id, string name) { var profile = _profileRepository.GetById(id); profile.Name = name; _profileRepository.Save(profile); //this calls SaveOrUpdate() //session.Commit() gets called in global.asax on Application_EndRequest() //profile.Name is changed in the database } Since my...

NHibernate to access Oracle stored procedure REFCURSOR and output parameter

Does the current version of NHibernate (v2.1.2) support access Oracle stored procedure output REFCURSOR in addition to an output parameter? I can access the output refcursor fine with my code. However i'm not sure i can access the additional output param in the same stored procedure. Some sample of calling syntax would be greatly appre...

NHibernate, how to map a property to a subselect

I currently have a legacy system that uses SPs exclusively for access to the DB. My domain object looks something like this: public class User : EntityBase { public virtual string Name {get;set;} public virtual string CreatedBy {get;set;} public virtual DateTime CreatedDate {get;set;} } The SP I have that mapped this looke...

Complex Nhibernate Query using Criteria

Can someone put this into Nhibernate Criteria ? select u.* from dbo.tblPunch p inner join tblUsager u on u.USAGER_CODE = p.userId inner join ( select distinct(userId), max(datecreation) as DateLastPunch from dbo.tblPunch where ServiceId = 76629 group by userId ) lastPunch on p.userId = lastPunch.UserId and p.DateCreation = lastPunch.Da...

Entity Framework v4 and Spring .Net

I would like to know if anyone used EF4 with Spring .Net in a WCF service. How easy it is to use DI with EF4 and other pros and cons. Currently I'm using nHibernate as ORM with Spring .Net as a data access layer. Are there good reasons to move to EF4? ...

Hibernate, assigning multiple columns as primary key

Hi, I am having below database schema. Table:items item_id int(11) autoincrement not null item_name varchar(22) not null version_start_date datetime not null version_end_date datetime The primary key for above table is (item_id,version_start_date). The semantics of version_start_date and version_end_date is to keep track of any chang...

What is the preferred way of using unsupported SQL functions or clauses with Castle/NHibernate?

I modeled all of my tables and already ported most of my queries using detached criteria's. All is working very well however I'm at a point where I don't know how to advance. I have a sub-query that uses Oracle's "connect by" clause. How do developers typically overcome that limitation of Castle/NHibernate? I am using the latest version...

NHibernate: Conditionally load a calculated column

I have the following proprty <property name="Allocated" type="decimal" formula="(select sum(a.AllocationAmount) from Allocation a where a.TransactionId = TransactionId)" /> This loads the amount of a Transaction that has been allocated to invoices which is working beautifully. However, is most cases I don't care about this amount. ...

Query property of enum collection mapped as element

Hi, I have the class with enum property collection: public enum PropertyType { Apartment, Townhouse, AndSoOn } public class Company { private readonly ISet<PropertyType> desiredPropertyTypes; public virtual ISet<PropertyType> DesiredPropertyTypes { get { return desiredPropertyTypes; } } // other stuff... }...

Any type mapping with different Id types

Hi there, I'm working on an event-planning application for the contacts in a phone book. Avoiding all the public virtual and protected stuff, my Contact class looks like: class Contact { //... Int32 Id { get; private set; } //primary key; String Name { get; private set; } //... } A customer asked me to handle both h...

Populating dropdowns/selection lists

Hello! I'm still in the process of learning DDD. I'm writing an ASP.NET MVC Application and I have several drop downs that I need to populate from the database. I've created mapped entities for every type (status, result, etc.) What I can't figure out is from where I should be getting the data. Creating a separate repository for each ...

Fluent NHibernate JoinedSubClass is obsolete

Hello! I wonder about something. I'm sitting here with a solution there I have 1 superclass that has 2 subclasses and I'm currently mapping this using JoinedSubClass, but I get that this method is obsolete, and says that I should ClassMap and SubClassMap, but if I do this the AutoMapping does not work, and I don't want that. Is there an...

fail-safe cleanup (collections) warning after committing transaction with NHibernate

When looking in NHProfiler I get following warning after committing my transaction: fail-safe cleanup (collections) : NHibernate.Engine.Loading.CollectionLoadContext I have absolutely no idea what this could be or how I can solve this. Can somebody help me? Thanks, Jelle ...

NHibernate query returns changes not yet persisted to database

Hi, The following unit test fails, I make changes to an object that I've retrieved and then in the same session I make a query which appears to take into account the uncommited changes I've made to the object. How can I get NHibernate to ignore any uncommited changes and only query the database? [Test] public void Test() { // Arra...

How to pass unit of work container into constructor of repository using dependency injection

I'm trying to work out how to complete my implementation of the Repository pattern in an ASP.NET web application. At the moment, I have a repository interface per domain class defining methods for e.g. loading and saving instances of that class. Each repository interface is implemented by a class which does the NHibernate stuff. Castle...

Set NOCOUNT OFF at database level?

Hello all. Can I set NOCOUNT to be OFF by default for a particular database? I need it for NHibernate (if it's ON, I get exceptions when saving). I can see the setting to disable it for an entire server (where it's set ON), but we're sharing the server with other databases. Is there a way I can set it to OFF just for my database? Or i...