nhibernate

Why SessionFactory in NHibernate is factory?

What stands for Factory postfix? Thx. ...

Updating schema of production database with NHibernate and adding default data

I'm looking for some ideas on how other people are managing the following situation - I've got some ideas but they seem a little messy and I can't help thinking I'm missing something. Here's the situation: You're using NHibernate with Fluent NHibernate for mappings. You have an application in production with a database with live data ...

Transfering SQL to NHibernate Criteria APi

I have this SQL here that needs to be transfered to NHibernate Criteria API: select nn.* from NetworkNumber nn inner join (select number, max(Version) ver from NetworkNumber group by number) b on b.number=nn.number and b.ver=nn.version If anyone has a good knowledge of it, I'd appreciate a lot. In the meantime - I'll keep trying and...

Fluent NHibernate PersistenceSpecification can't test a collection of strings

I'm using Fluent NHibernate to map a a class that has a collection of strings like this: public class Foo { public virtual ICollection<string> Strings { get; set; } } public class FooMap : ClassMap<Foo> { public FooMap() { HasMany(f => f.Strings).Element("SomeColumnName"); } } When I write a unit test using the PersistenceSpe...

NHibernate query count

Hi, I am new to NHibernate and I want to have a count of rows from database. Below is my code, SearchTemplate template = new SearchTemplate(); template.Criteria = DetachedCriteria.For(typeof(hotel)); template.Criteria.Add(Restrictions.Lt("CheckOutDate", SelDate) || Restrictions.Eq("CheckOutDate", SelDate)); ...

Unable to create strongly typed view in VS2010 with Fluent Nhibinate and MVC2

HI, I was wondering if any one else had had a problem with VS2010 MVC 2 projects not being able to automaticly create a strongly typed view after doing a fluent mapping? When trying to do the mapping VS2010 doesnt show the Entities in the drop down and even if i manually put the class in it doent auto build the view . Cheers Dan ...

NHibernate - Commit Doesn't Always Work but No Error Thrown

Hi, i have a weird issue when committing changes in NHibernate. It doesn't throw an error but only about 20% of the time the changes are committed to the database. I know it sounds like a strange question and without code you won't be able to help much but i was just wondering what's the best way to debug this. Appreciate your advice....

Mystery NHibernate Select Issue

Hello, I've got a situation where for some users, NHibernate is consistently locking or stalling or something in the middle of issuing select statements: 2010-09-25 16:17:29,161 [8] INFO NHibernate.Loader.Loader - SELECT applicant0_.Id as Id15_1_, applicant0_.FirstName as FirstName15_1_, applicant0_.MiddleName as MiddleName15_1_, appli...

Is it possible to do create a generic Session.QueryOver<T> ?

Out of curiosity is it possible to do something like this using NHibernate 3? public IQueryable<T> FindAll<T>() { return Session.QueryOver<T>().List().AsQueryable(); } I get a compilation error saying something like... The Type T must be a reference type in order to use it as a parameter T. I was wondering if I could create an ex...

Can NHibernate use internal types?

Hello, I'm a little bit of an NHibernate noobie, and I was wondering if NHibernate can work with internal types. I have a project with a bunch of internal entities, and I would like to use NHibernate within the project to access my data store. If I put the mapping files in the same assembly (or is this even necessary?), will NHibernate...

NHibernate many-to-many criteria.

I have entity Problem mapped using many-to-many to entity Tag (Problem has a list of tags). I want to load all the Problems, which have specific Tags. For example: Problem1 (tag1) Problem2 (tag1, tag2) Problem3 (tag1, tag3) Problem4 (tag3, tag4) I want to get the problems by filter "tag1, tag2". The system shall return: Problem1 (tag1) P...

Join in nHibernate

Hello All , I have the following entities public class Category { Id Name } public class Product { Id Name List<Category> list; } what I want to do is get all the product by category name using nHibernate any help will be appreciated Thanks in Advance ...

Inheritance in nHibernate

Hello All, I have the following entities public abstract class ProductAttribute { public virtual long Id { get; private set; } public virtual string Name { get; set; } } public class TextAttribute : ProductAttribute { public virtual string Value { get; set; } } and public class Product { public virtual long I...

customize error message for nhibernate

when deleting an entity in nhibernate i get an exception with this error message: delete statement conflicted with column reference constraint ..etc of course the exception is wrapped in long series of exceptions. the error message is normal, but can i make nhibernate shows more polite error message to the user ?? in another words: is t...

nhibernate Antlr.Runtime.NoViableAltException

return NHibernateSession.CreateQuery(@"TRUNCATE TABLE dbo.Exceptions").ExecuteUpdate(); Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [TRUNCATE TABLE Exceptions] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more info...

Difference between NHibernate SessionFactory and EF 4.0 ObjectContext

In NHibernate SessionFactory is said to be a heavy object and it is suggested that SessionFactory should be created once in application life span. However once we get handle to SessionFactory, we do call open() on it before doing any DB operation. In EntityFramework we need to create an object of ObjectContext every time before doing an...

Delete records that don't exist in a given list using NHibernate

I have a Video entity that has multiple Genres, public class Video { public int Id { get; set; } // other fields omitted for brevity public IList<Genre> Genres { get; set; } } public class Genre { public int Id { get; set; } public string Name { get; set; } // fields omitted for brevity } Initially I popula...

Using NHibernate query to query NOT IN with JOIN statement

select alphanum from sampler where alphanum not in (select sampler.alphanum from sampler, samplerassignment where sampler.alphanum = samplerassignment.alphanum and isactive = 1); I have this statement and would like to use NHibernate query to execute it. How shld I write it in NHibernate? ...

put just the key type (id) or the class type for FK in entities, pros and cons

I've seen 2 types of entities, like this: public class Person { public int Id {get;set;} public string Name {get;set;} public Country Country {get;set;} } and like this: public class Person { public int Id {get;set;} public string Name {get;set;} public int CountryId {get;set;} } I think that the 2nd approac...

using nHibernate to cast unmapped data into a DTO

Hi, So I'm doing a postcode lookup provided by an outside data provider on a database that we're controlling with nHibernate. This involves calling a stored procedure and supplying a postcode. In return I get a number of rows each one of which contains multiple columns that make up the parts of the address. We have an address DTO. But ...