nhibernate

NHibernate Mapping Attributes + Spring

Hello everyone, I'm working on a C# .NET project in which I am mapping my classes to the tables in my database with NHibernate. I need to use NHibernate.Mapping.Attributes and transactions to be configured by Spring. The fact is that Spring 1.3.0 provides a sample project called "Spring.Data.NHibernate.Northwind" that almost provides a...

NHibernate ManyToMany Relationship Cascading AllDeleteOrphan StackOverflowException

I have two objects that have a ManyToMany relationship with one another through a mapping table. Though, when I try to save it, I get a stack overflow exception. The following is the code for the mappings: //EventMapping.cs HasManyToMany(x => x.Performers).Table("EventPerformer").Inverse().Cascade.AllDeleteOrphan().LazyLoad().ParentKeyC...

How to save a large nhibernate collection without causing OutOfMemoryException

How do I save a large collection with NHibernate which has elements that surpass the amount of memory allowed for the process? I am trying to save a Video object with nhibernate which has a large number of Screenshots (see below for code). Each Screenshot contains a byte[], so after nhibernate tries to save 10,000 or so records at onc...

Flush separate Castle ActiveRecord Transaction, and refresh object in another Transaction

I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and ...

NHibernate DuplicateMappingException when mapping abstract class and subclass

I have an abstract class, and subclasses of this, and I want to map this to my database using NHibernate. I'm using Fluent, and read on the wiki how to do the mapping. But when I add the mapping of the subclass an NHibernate.DuplicateMappingException is thrown when it is mapping. Why? Here are my (simplified) classes: public abstract...

Compare term to current date in HQL (with .Net)

Hello, I want to compare a column value to the current date, using HQL. I tried IQuery someQuery = session.CreateQuery(String.Format( @"Select s.Id From InventoryProductStateItem s where s.ValidFrom < current_date()")); This throws the exception "Incorrect syntax near keyword current_date()" curre...

What methods other than NHProf allow you to view the dynamic SQL generated by nhibernate?

Before NHibernate Profiler was released I was parsing through logs generated by log4net. Today I use NHibernate Profiler, but what other tools / techniques exist that allow a developer to view the dynamic SQL generated by nhibernate? ...

How to resolve conflicting assemblies in .Net?

In my web application I am using NHibernate.dll. This has a dependency on folowing assembly. 'Antlr3.Runtime, Version=3.1.0.39271, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7' Now in the same project for another requirement I have to introduce Antlr3.StringTemplate.dll. Which has a dependency on another version of the abov...

Select latest group by in nhibernate

I have Canine and CanineHandler objects in my application. The CanineHandler object has a PersonID (which references a completely different database), an EffectiveDate (which specifies when a handler started with the canine), and a FK reference to the Canine (CanineID). Given a specific PersonID, I want to find all canines they're curr...

Fluent Nhibernate - Mapping two entities to same table

Hi, I'm trying to map two domain entities to the same table. We're doing a smart entity for our domain model, so we have the concept of an Editable Address and a readonly Address. I have both mapped using Classmaps, and everything seems to go fine until we try to export the schema using the SchemaExport class from NHibernate. It erro...

NHibernate Many-To-One on Joined Sublcass with Filter

I have a class setup that looks something like this: public abstract class Parent { public virtual bool IsDeleted { get; set; } } public class Child : Parent { } public class Other { public virtual ICollection<Child> Children { get; set; } } Child is mapped as a joined-subclass of Parent. Childen is mapped as a Many-To-One b...

Should i care/have knowledge about nHibernate before choosing Fluent nHibernate?

I was going through Fluent nhibernate wiki and i know that Fluent nhibernate is built on top of nHibernate... Should i care/have knowledge about nHibernate before choosing Fluent nHibernate? Any suggestion... ...

NHibernate. Current server datetime()

Hello. At my domains for audit purposes I've got UpdatedOn property. Now I set it at client before updating to DateTime.Now. But a lot of users have incorrect datetime at theirs machines, so i need use server datetime (getdate(),now()...) How can i implement this strategy? ...

nHibernate Update leaving orphaned rows

Hi, Using Fluent nHibernate on my database. I'm perplexed as to why one of my .Update statements seems to create new data and leave the old data in the table as orphaned rows without a key. Take this as an example: the problematic object is a "MetaData" object which has a many-to-one relationship with a "Page" object (a Page can have ...

set transaction must be first statement of transaction With Spring.Data.NHibernate12

Hi , I am using Spring.Data.NHibernate12 on my database level.my application connection with database is not getting released.Sometime in Nhibernate log i am getting set transaction must be first statement of transaction .Setting transaction tag on top of the function. Underneath given is Dataconfiguration.xml <?xml version="1.0" ...

Retrieve all records in a table with nHibernate

I need to retrieve all the records in a table with nHibernate. If I had the key for all the records in the table I could loop and use nHibernate's Get method (this seems inefficient though) but I don't have the keys. I could also use FindAll but this requires criteria or a stored procedure. How can I get all the records from the table...

How to get number of delete using NHibernate IStatistics

I am trying to get the number of delete statements issued during the session, so I enabled statistics generation and I got a reference to it through SessionFactory.Statistics. But I don't see a way to get the global number of deletes. I can get the statistics for the entity, but I have one many-to-many mapped relationship that does not ...

With NHibernate, how can I create an INHibernateProxy?

After lots of reading about serialization, I've decided to try to create DTOs. After more reading, I decided to use AutoMapper. What I would like to do is transform the parent (easy enough) and transform the entity properties if they've been initialized, which I've done with ValueResolvers like below (I may try to make it generic once I...

nHibernate <one-to-one> mapping

Please help me out I am trying to do this but nHibernate not allowing can any one help me out how to do this? ...

Total runtime checks and NHibernate

Would a increasing value of performace counter total runtime checks indicate a performance issue, when it seems to be coming from Session.Linq of NHibernate? This has been measured in a asp.net environment. Regards ...