nhibernate

Using NHibernate to execute DDL statements

How can I execute a DDL statement via NHibernate? To be clear, I don't want to auto-generate my schema from my mapping files. My DDL is stored in plain text files along the lines of: CREATE TABLE Foo (Bar VARCHAR(10)) GO CREATE TABLE Hello (World INTEGER) GO I want to cycle through these in order and execute each of them. I could jus...

NHibernate identifier altered exception

Hi, I am trying to import some large files using batch queries and paralel processing and I'm constantly getting errors like NHibernate.HibernateException: identifier of an instance of xxx was altered from ... to ... I know I am not modifying my primary key at all. I am using NH 2.1.x GA, ThreadStaticSessionContext, every file is proc...

How to handle NHibernate session lifetime using services?

In this question I asked about NHibernate session lifetime. I'm using a desktop application, but with client/server separation, so the conclusion is that I will use one session per server request, as the server side is where all the NHibernate magic happens. My problem now is how to handle it. I've had problems before with loading of r...

Fluent NHibernate (with automapping) not saving join table values in many-to-many

I am not exactly an NHibernate expert, so this may be a lack of understanding in that department. I have two simple entities with a many-to-many relationship public class Category { public virtual int Id { get; private set; } public virtual string Name { get; set; } public virtual string Description { get; set; } public ...

how do I map this?

I am sure I am stupid (which some arrogant clerk at my bank just explained to me) but I don´t get how to map this: lets say I have a table tbl_products with a ID column and a tbl_language with a ID column and my problem: a tbl_product_texts without any id of its own but a product_id and a language_id (and a lot of texts in a couple of l...

Why does NHibernate first insert and then update element of a collection?

I'm not sure if it's a correct behavior or something done wrong on my side: I've got a very simple parent-child relationship public class SubmittedBatch { public virtual Guid Id { get; set; } public virtual IList<SubmittedBatchParameter> Parameters { get; private set; } } public class SubmittedBatchParameter { public virtu...

Is there any way RIA Services Query Method can take Entity as Parameter?

I have zero way to pass a query to RIA Services. You see; I have the unfortunate task of running NHibernate over Oracle, behind RIA Services and are not using NHibernate.Linq. So, is there any way, any way at all to pass a object, my request object, back to a query? ...

Nhibernate not returning right result sometime

Hi Guys, So here is my nhibernate query. I am just querying in database if there is latest entry by some number but with latest time stamp. So like if I have Row A 6 1/7/2010 2:55:59 PM Row B 6 1/7/2010 2:56:33 PM So According to the query it should return Row B but sometimes it is not happening. Can anyone point out the...

Updating the collections of entities with NHibernate the correct way

A simple question regarding how NHibernate works: I have a parent entity that has a collection of other child entities. Those child entities have a reference to the parent entity they belong to. Now I want to implement an Add method to the parent entity that would add a child to it. Should that Add method only add the child to its new pa...

write the hibernate query to retrieve data with latest timestamp.

I want to retrieve unique data froma table based on latest time stamp. So If I have a table like this guid 6 1/7/2010 9:55:29 PM guid 6 1/5/2010 2:59:29 PM guid 6 1/7/2010 2:55:29 PM I need to write a query where I can query with no 6 and with latest timestamp in the same table. So it should return me : guid 6 1/7/2010 ...

NHibernate and database changes/deployment

I'm looking into using NHibernate and Fluent NHibernate for my next project but one thing I'd like clearing up before hand is how do you manage changes to the database? eg, I have NH + FNH working, application has been deployed and is live but we make a change in the development environment, for example say we add a new property to a en...

How do you delete a referenced object when the reference changes in NHibernate?

I have two entities like so (distilled to only what's relevant): public class Person { public virtual Address Address } public class Address { } Person has a many-to-one relationship with Address, or in object terms, a Person references an Address, and this link is uni-directional (Address does not have a reference back to Person...

DateTime precision in NHibernate and support for DateTime2 in NHibernate SchemeExport

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO class: public class Foo { public virtual int Id { get; set; } public virtual datetime CreatedDateTime { get; set; } } The CreatedDateTime field will map to a SQL DateTime by default. However if I do a test to check ...

NHibernate Cascade none still updating related entity.

Hi, I am then using Fluent NHibernate and its automapping feature to map the the following simplified POCO classes: public class Webpage { public virtual int Id { get; set; } public virtual string UrlIdentifier { get; set; } public virtual WebpageType WebpageType { get; set; } } public class WebpageType { public vi...

NHibernate Interceptor - What is it

I am new in NHibernate, you can say I am almost at dummy level :( . What I want to know is that what is NHibernate Interceptor, and for what purpose does it serve in an application? Also, in this article, I learned that using NHibernate makes a desktop application slower at startup, so to avoid this, I need to save the configuration in ...

Transform LINQ IQueryable into a paged IQueryable using LINQ to NHibernate

Hi! I wanna do something like that public IQueryable GetPaged<TSource>(IQueryable<TSource> query, int startIndex, int pageSize) { return GetSession() .Linq<TSource>() .UseQuery(query) .Take(pageSize) .Skip(startIndex); } So you can put any IQuerable statement and "it become...

how to ignore a property by attribute in nhibernate

How can i ignore a property by decorating a property with an attribute? the base class AttributePropertyConvention doesn't seems to have that ability, or can it? Doesn't find anything sutiable on IPropertyInstance to set.. ...

ASPNET MVC Session per request pattern and IHttpModule

Hi Im trying to make a solution like this http://stackoverflow.com/questions/1391060/httpmodule-with-asp-net-mvc-not-being-called Now the question is how do I filter the request, I only want to Open an ISession if the request is for an ASPNET MVC Action, not for *.gif, *.css etc. How should I handle this filtering? ...

Generate XML mappings from fluent Nhibernate

How do I generate xml mappings files as part of my tests in MappingIntegrationTests I need to manually check if the fluent mappings correlate to the mappings in the leagcy project. ...

Examples of Design Patterns used in Open-Source .Net projects

I am looking for examples of open-source projects that have made use of different design-patters. One example that comes to my mind is use of Proxy Pattern in NHibernate Help me find more ...