nhibernate

Automatically update child collection IDs after insert in bidirectional one-to-many association

I'm sure this problem has been addressed before but I can't find a 'duplicate'. So the question is: I have a bidirectional one-to-many association: document and comments. The comments table has a foreign key (not nullable) pointing to documents table. The classes are: public class Document { public virtual Guid Id {get; set;} pub...

Insert 100k rows in database from website

Hi all, I have a website where the user can upload an excel spreadsheet to load data in a table. There can be a few 100k rows in the excel spreadsheet. When he uploads the file the website needs to insert an equal amount of rows in a database table. What strategy should i take to do this? I was thinking of displaying a "Please wait pa...

Nhibernate hql left join question

Hi, Is it possible to do a left join like this in Nhibernate: SELECT T.title_id, T.title, S.qty FROM titles T LEFT JOIN sales S on T.title_id = S.title_id AND S.stor_id = '7131' ORDER BY T.title The important part to note is the extra clause (AND S.stor_id = '7131') in the LEFT JOIN expression. Can I do this in Nhibernate hq...

Why doesn't session.CreateCriteria(typeof(...)) fail for an unmapped type?

For every entity that I create I write a unit test that just loads one record from the database to see if the query works and the data can be set on the entity correctly. You could see this as a unit test for the basic mapping. This should also confirm that a mapping file exists for the type and is set as embedded resource. The test loo...

NHibernate sqlite database providers configuration

I'm writting simple application and i'm stuck in the defenition process it seems i'm lacking a reference or a dependency but after reading every blog/forum/starter kits i couldnot find the answer i hope you'll be able to help me I defined an employee class and mapping object with id, name and age created a database using sqlite and cre...

NHibernate Mapping Attributes + Dirty Checking

Hello everyone ! I have problems with NHibernate updating some of my entities when this is not supposed to happen (dirty checking). As I use NHibernate.Mapping.Attributes to map my classes, I have found that there is a parameter "Check" to the element "Class" of NHMA. I would like to know if I can turn off dirty checking by setting thi...

Can you perform complex aggregate operations using NH3?

I need to perform a grouping aggregation similar to something like this in T-SQL: select b.Name as [Grouped Name], COUNT(distinct a.ID) as [Grouped Count], COUNT(distinct c1.ID) as [Second Group Count], COUNT(distinct c2.ID) as [Third Group Count] from TableA a left join TableB b on a.ID = b.TableAID left join TableC c1 on a.ID = c1.T...

NHibernate - How to map users belonging to both accounts and stores?

Hi, We have many accounts and an account can have many stores and now I have users. A user could potentially belong to either an account or a store. Like below I just feel like this is insanity and was hoping for some guidance in the matter. These are my requirements. A user belonging to an account should have access to all the stor...

nhibernate: many-to-one using multiple columns

So I have scavenged the internet for a while now and am still stumped on this current issue I am facing with nHibernate: I have two tables that I have mapping files for. Table A stores information about "Things", and Table B stores how these "Things" are related. The problem is as follows. Table A is mapped to the Thing class. Table B n...

Fluent NHibernate with DB2 problem

I have a project that is using Fluent NHibernate. When I try to use the DB2Configuration to connect to a DB2 database I receive the following error when trying to build the SessionFactory: "The IDbCommand and IDbConnection implementation in the assembly IBM.Data.DB2 could not be found. " The assembly that is included in my install of I...

EnableFilter is not available on IStatelessSession but ISession ( NHibernate 2.0 )

IStatelessSession does not have some of the functions like EnableFilter. Is there an alternative to this method on stateless session ? Does IStatelessSession support lazy loading ? Is there a way to convert ( or cast ) ISession to IStatelessSession ? we are upgrading our code base with NH 2.0 and there are lots of code in DAL layer tha...

NHibernate, ORM : how is refactoring handled? existing data?

When using an ORM (specifically NHibernate), how is refactoring of data handled? I mean, if data objects change such that the underlying relational DB schema changes, does the ORM offer any help in schema upgrades / downgrades in the DB? How about migration of existing data to the new schema? I am in the process of making a decision on ...

Mapping properties from a foreign table twice in Fluent NHibernate

I have 2 tables like this: (Please note the non-standard db schema naming) table T_Pen TP_ID TP_PrimaryColorID TP_SecondaryColorID ... table E_Color EC_ID EC_ColorName ... And I want to create a mapping of the 2 tables to a domain object Pen using Fluent NHibernate. class Pen { PenID; PrimaryColorName; Seco...

NHibernate SchemaUpdate adding existing foreign keys again?

I'm using SchemaUpdate to synchronize my hbms with existing database. Database has recently created based on hbms and is completely up-to-date. But SchemaUpdate generates all foreign key constraints again. For example suppose you have Student and Teacher. Student has association to Teacher with name ArtTeacher. ArtTeacher is a foreign ...

multiple unique keys in nhibernate

I need constraints created in the following manner: CONSTRAINT [IX_Unique_1] UNIQUE NONCLUSTERED ( [Ordering] ASC, [Description] ASC ), CONSTRAINT [IX_Unique_2] UNIQUE NONCLUSTERED ( [Description] ASC ) I have the following nHibernate mapping: <property name="Description" column="Description" type="String" unique-key="IX...

Can I use NHibernate on Windows Phone 7?

Can I use NHibernate on Windows Phone 7? ...

Nhibernate IPreUpdateEventListener fails to update child object

I've attached an IPreUpdateEventListener to nhibernate and not getting the results I expect (saving of a child object). This object has history attached to it and if certain things change, it needs to reflect this and save it, no big deal right? Given the entity as such -- assume ListOfHistory is newed up in a constructor ... pub...

Unable to locate my nhibernate config file when debugging my MVC web-application

I've got an MVC web-project that's referencing a class-library-project that contains my Domain and Persistence tiers. I'm using nHibernate for my OR/M. Since I've got multiple databases to connect to, I'm initializing my session-factories by specifying the file-names: var config = new Configuration().Configure(nHibernateCfgFileName) ...

Fluent Nhibernate : Unexpected row count: 0; expected: 1

Hell All, ** Solved as of now Please see Edit 2 and Edit 3 ** I am NHibernate Newbie- a week old but I though working with it will save me time on new project and not otherwise. I have been banging my head trying to get Nhibernate to save Parent - Child Collection to SQL server database. My Class Map : public class OrderMap : Clas...

MySQL Configuration for Fluent NHibernate

Hi all! I have class-configurer fluent nhibernate for MySQL: class MySqlInitializer : INHibernateInitializer { public Configuration GetConfiguration() { var dbServer = "localhost"; var dbUsername = "root"; var dbName = "nhibernate"; var dbPassword = ""; var ormAssembly = "NHibernate_MySQL....