nhibernate

Storing a Set of Integer values in Sql Server 2005 with nHibernate?

What is the best way to store and map an Entity which contains a set of Integer as one of its attributes? I am using nHibernate over Sql Server 2005. Will creating a CLR Custom Type will help here? If yes how it can be mapped using nHibernate? I should be able to query on the Set. E.g. select myEntity from MyEntities where myEntity.In...

NHibernate (not Fluent NH) - Is it possible to reuse components?

Is there any way to reuse NHibernate components (<component>) in more than one mapping? For example: an Address class in Employee and Customer classes - The only way to do this which I see now is to copy-paste the Address component mapping from one of the class mappings into another. ...

Nhibernate Facility Lazy loading problem

I am migrating my mvc web app to use Nhibernate Facility to manage Nhibernate sessions. I am encountering this strange problem; When I register SessionWebModule under web.config/ httpmodules via: <add name="NHibernateSessionWebModule" type="Castle.Facilities.NHibernateIntegration.Components.Web.SessionWebModule, Castle.Facilities.NHib...

NHibernate ISession specific event listener

Hi, I'm creating a multi-tenant ASP.NET application using NHibernate (shared schema). I had intended to use NHibernates Event Listeners to inspect/modify entities prior to saving to ensure that the current tenants ID was being saved against the entity. The authentication token containing the tenant ID is managed higher up and passed do...

Why timeout may occur in SqlConnection.Open()?

What are the cases when timeout occurs in SqlConnection.Open()? On one of our IIS boxes 10 seconds after AppProcess was recycled the following exception appeared: Type : System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message : Timeout expired. The timeout period e...

How to determine if nHibernate object changed

Hi, Probably a stupid question but I'm still trying to wrap my head around nHibernate. As far as I can tell from using the software, nHibernate requires you to do a little bit of extra handling for saving changes properly. Let's imagine I have an object X which can contain many of object Y. I'll create an X which has 2 Y's, each of wh...

Eager Loading Using Fluent NHibernate/Nhibernate & Automapping

Hi guys, I have a requirement to load a complex object called Node...well its not that complex...it looks like follows:- A Node has a reference to EntityType which has a one to many with Property which in turn has a one to many with PorpertyListValue public class Node { public virtual int Id { get; set; } ...

Need some explanations on NHibernate many to one relationships

Hello everybody, would you mind help me to better understand what to do with the relationship between my entities and NHibernate? I have some difficulties to understand what operations I need to do by hand, and what operations NHibernate will do for me (or not). I have these 2 entities: public class Position : BaseEntity<int, Positio...

NHibernate - object references an unsaved transient instance - save the transient instance before flushing

I'm getting the following error: object references an unsaved transient instance - save the transient instance before flushing I do not want to save the transient instance. I'm trying to send validation results back to the client: if (MyObject.IsValid()) { MyObjectRepo.Hydrate(MyObject); return Json(My...

Is there a way to stop referencing a child object in NHibernate without flushing the session or removing its parent from the session cache?

I'm building a standard old thick client with NHibernate where the majority of my entities (see class A) are dehydrated at application start and stay there for the app lifetime. These occassionally reference are a couple of very heavyweight classes (class B) that encapsulate a lot of data which are lazily loaded proxies so that they are ...

NHibernate YesNo on SQL-Server CE No mapping exists from DbType AnsiStringFixedLength

Trying to use nhibernate on sql-server compact edition for unit testing and having some trouble. At the moment I just have one entity which is: <class name="Audit" table="eolaudit_llk"> <id name="ID" column="eolauditlk_ky"> <generator class="identity"></generator> </id> <property name="Name" column="eolauditlk_nm" /> <property name=...

Invalid object name 'hibernate_unique_key

I have this error when i try to save my entity: Invalid object name 'hibernate_unique_key What is the problem? With the SQL profiler i have this query: select next_hi from hibernate_unique_key with (updlock, rowlock) Can you help me? I'm using Asp.net mvc 2, Sharp Architecture (with fluent automapping) Thank you ...

Fluent nHibernate causing orphaned rows

Hi, I'm having problem with a loop which is supposed to add nHibernate objects to an existing nHibernate objects and save. There's a whole tree of relationships here there's a Page object which can have many Region objects which in turn can have many Row objects which can have many Asset objects - the problem is somewhere in the latter ...

Service behaviour in Entity - how to avoid service injection into entity?

Hi, I have an entity structure as follows: IManager: IDeletable { IEnumerable<IFund> Funds {get;} IFailureNotification Delete(); } IFund : IDeletable { IEnumerable<IFundClass> FundClasses IFailureNotification Delete(); } IFundClass: IDeletable, IInvestable { IFailureNotification Delete(); } And I have a service which takes an IDele...

How to choose that which ORM would be feasible for or Application? e.g if we are using Linq then why not hibernate

How to choose that which ORM would be feasible for a web Application? e.g if we are using Linq then why not nhibernate? and Which one is better and why ...

NHibernate Component inheritance

Is it possible to do inheritance with NHibernates component? A quick google returned only a hand full of appropriate results (all blogs) and all were written some time ago so was wondering if it is available yet? if not how do you handle it instead? ...

NHibernate SQLquery for paging to HQL / ICriteria

Hello everyone! I'm making a query that sorts and returns X rows based on row_number() I'm using NHibernate with MSSQL and im trying to get paging working using CreateSQLQuery and i have this query: select s.* from( select distinct release.[stop], survey.SurveyId, survey.Created, survey.CopyOfId, survey.DesignTemplateId, survey.Us...

Silverlight: Lazy loading from nHibernate

I've recently been using/working on an open source project for Flex/Java/BlazeDS which facilitates lazy loading of Hibernate entities & collections in Flex. (Ie., solves the org.hibernate.LazyInitializationException exception when serializing) This issue has long been a problem for Flex/Java/Hibernate developers. dpHibernate solves th...

NHibernate and inheritance creating unexpected double query behavior?

I'm using FluentNHibernate. I am not using auto-mapping. I have a base class that is subclassed. When I query against the base class then it performs an extra query against the subclass. Here's the (contrived) example of what I'm doing: public class Foo { int Id; string SomeValue; } I create another class that represents a...

Nhibernate Hql query retrieve DateTime empty

Hi I need hql query for retrieving objects with an empty value in a datetime property Something like that from Users u where u.LastLogon is empty LastLogon is a DateTime? property, datetime in the MS Sql Table How can you do that? ...