nhibernate

NHibernate.Spatial and Sql 2008 Geography type

hi there, i'm currently working on a project where i have to deal with sql server 2008 geography types. As big parts of the projects uses NHibernate as ORM i wonder how much work it will be to use/extend NHibernate.Spatial with this type (as far as i can see Nh Spatial only supports the geometry type yet). Btw. are there any other .net ...

How to map to get value from primary table in Nhibernate?

I face a problem when I try to get value from primary table in my mapping file. My tables: CREATE TABLE Customer ( [CustomerId] INT PRIMARY KEY, [FullName] NVARCHAR(50) NOT NULL ) CREATE TABLE CustomerOrder ( [CustomerOrderId] INT PRIMARY KEY, [CustomerId] INT, [TransactionDate] DATETIME ) My classes: public cla...

How to create OR statements for NHibernate?

Hi folks! When creating a criteria for NHibernate all criteria are added as AND. For instance: session.CreateCriteria(typeof(someobject)) .Add(critiera) .Add(other_criteria) then end result will be SELECT ... FROM ... WHERE criteria AND other_criteria I would like to tell NHibernate to add the criterias as "OR" SELECT ... FROM .....

Changing the initial LazyLoad behaviour in NHibernate

I've just started using NHibernate and fluent-NHibernate which I think is great. I've been configuring all my mappings to use LazyLoading for any relationships between classes because generally I find it isn't neccesary to load everything upfront. However sometimes you know 100% you will be loading all of the relationships or at least on...

DI/IoC, NHibernate and help in getting them to work together.

I'm trying to get my head around DI/IoC, NHibernate and getting them to work nicely together for an application that i'm developing. I'm quite new to both NHibernate and DI/IoC so not quite sure whether what i'm doing is the sensible way to be going about it. This is the scenario: The application provides users with the ability to calc...

nHibernate Master Detail Deletion

I have a Master Detail relationship configured. The hbm file is below. When I run some code like this Favourite favourite = favourites.Find(f => f.Id== id); user.Favourites.Remove(favourite); m_UserRepository.Save(ref user); I get the error message NHibernate.Exceptions.GenericADOException: could not delete collection rows: [Model.En...

NHibernate mapping - one-to-one (or one-to-zero)

NHibernatians! I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended]. [Wibble] is the main table and [WibbleExtended] is an optional table where some other fields are stored. There are far fewer entries in the [WibbleExtended] table than the main [Wibble] table. I think this was done back in the day to cure some spac...

NHibernate: how to enable lazy loading on one-to-one mapping

One-to-one relations within nhibernate can be lazyloaded either "false" or "proxy". I was wondering if anyone knows a way to do a lazy one-to-one mapping. I worked out a hack to achieve the same result by using a lazy set mapped to a private field, and having the public property return the first result of that set. It works, but isn't t...

Can you mix Fluent NHibernate and Traditional hbm.xml

We have some mapping already done in hbm.xml and I'd rather not have to map these programatically can you mix them in same sessionfactory until we have the time to repay the debt? ...

What is Tuplizer in NHibernate

I came across a post that mentioned Tuplizer in NHibernate, can anybody provide a good definition or reference for Tuplizer? ...

NHibernate Transactions in Open View per Session - suggested practices?

Cleaning up some transactional logic and wondered how other people were handling it. Ayende's recommendation seems to be to handle transactions at the service boundary. This is a ASP.NET web app though, so it hasn't got a clear cut service boundary, at least not right now. What do people do? Create a single transaction per request i...

NHibernate: Best way to map to DateTime a value stored in a non-standard way

I am just getting started with NHibernate (for the 15th time it would seem) and am having the following problem. The following table: Table Facility Column FACILITY_ID integer Column NAME varchar2(50) Column MONTH varchar2(5) For whatever reason, month is a string instead of a native Date type and looks like this: "200811" represent...

hibernate - pattern for mapping a default entity?

Is there a sleek way to map a default database object in Hibernate? For example, in this class, a Foo should always be able to return a Bar, whether it's custom defined for the Foo, or it comes from a default value that's stored in the database somewhere. Users of Foo should be able to set a custom Bar object in it, but they don't ne...

NHibernate Mapping intermediary table

Hi I'm looking for some help in mapping the following tables to a hibernate mapping file: I'm trying to fill the localCalandarGroups List with related localCalendarGroups when loading my userVOs. I'm using a intermediary table(user_localCalendarGroup) to keep the user and localCalendarGroup ids public class UserVO { public virtua...

NHibernate not persisting many-to-many relationship

Hello, I'm currently using NHibernate as my data access layer, using Fluent NHibernate to create the mapping files for me. I have two classes, TripItem and TripItemAttributeValue, which have a many-to-many relation between them. The mapping is as follows: public class TripItemMap : ClassMap<TripItem2> { public TripItemMap() { ...

Nhibernate, MVC and ModelBinders

I want to configure my model binders with Nhibernate: So I have: <object id="GigModelBinder" type="App.ModelBinders.GigModelBinder, App.Web" singleton="false" > <property name="VenueManager" ref="VenueManager"/> <property name="ArtistManager" ref="ArtistManager"/> I have an attribute which marks controller actions so that they us...

How to map NHibernate from table A to table A itself with many-to-many?

Please help! I couldn't figure it out how to map the following situation: I have only 1 table. [Table] User { id, name } My class look like this public class User { public int Id { get; set; } public string Name { get; set; } public ISet<User> Friends { get; set; } } Each user has relationship with other users. e.g.'User...

Castle ActiveRecord / NHibernate optimization question

Hi, I have the following structure: message (message table) may have multiple fields (fields table), and each field may have multiple subfields (stored in the same "fields" table with the only difference that fields dont have values in the "ParentField" column). Subfields may have subsubfields, etc., but this is not important. When I r...

Castle ActiveRecord / NHibernate optimization question, part 2

Sorry, didn't paste correctly in initial posting... Here is mapping file that ActiveRecord generates: <?xml version="1.0" encoding="utf-16"?> <hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2...

How do IN () statements work in NHibernate? (Using Criteria)

I'm trying to create the equivalent of the below using NHibernate. I've done all the mappings using fluent and I can do the basic queries just fine but I have no idea how to do this. -**Product Table** Reference Title Subjects (Many to Many relationship) Price -**Subject table** SubjectID Name -**SubjectToProductMapping Table** Refere...