nhibernate

NHibernate Stored procedure mapping properties on complex object

I have a SQL stored procedure which Im trying to use to load a collection of entities. My entities look like this public class Person { public virtual int Id {get;set;} public virtual string Name {get;set;} public virtual Colour FavoriteColour {get;set;} } public class Colour { public virtual int Id {get;se...

Separate table for Value Objects on NHibernate

Hello, I'm new to DDD and NHibernate. In my current project, I have an entity Person, that contains a value object, let's say Address. Today, this is fine. But maybe one day I will have a requirement that my value object (in this case Address), will have to become an entity. Before trying to model this on a DDD-way, in a more data-cent...

Problem on a query with NHibernate

Hi Guys, I have a very simple scenario, using NHibernate: one abstract base class "animal"; two concrete subclass "cat" and "dog" with discriminator column (1 for dog and 2 for cat); one normal class Person; Person have a many-to-one of animal. I want retrieve a list of person with a dog. How can I do this? thx a lot ...

NHibernate.Linq And CompareTo String

I'm using Linq and Hibernate and trying to compare to Strings one from a variable and the other from a Class Linked to Hibernate, the code: bindingSource.DataSource = (from search in Repository.GetAll() where search.cod_coluna.CompareTo(CurrentRecord.cod_coluna) > 0 orderb...

NHibernate: Initial Data Population

I am using NHibernate as my ORM, and for unit testing purpose I am using sqlite as a substitute database. In order to have meaningful unit test I need to populate the tables. How to do this in NHibernate? Even though my unit testing database is sqlite, I would prefer a db independent scripts that allow me to do that. Does Nhibernate ...

NHibernate: Session.Save and Transaction.Commit

Is there a difference between Session.Save and Transaction.Commit ? When I should use which? It seems that sometimes Session.Save must use in conjunction with Transaction.Commit, sometimes no. Can anyone tell why this is so? ...

Realize entity copy on NHibernate update

How can I make such behaviuor in NHibernate: There is an entity called User in my domain // I ommit mapping attributes public class User { int Id {get; set;} int pId {get; set;} //....other props, such as Login, Name, email... } I need to make full copy of it, when updating. pId must be set to original Id. Old entity must be un...

compare entities before update in Nhibernate (audit implementation )

Hi, I need to log in to database every user update on any record and need to store old and new value of any record which was changed. This audit is implemented as interceptor in nhibernate so i have method: public override bool OnFlushDirty( object entity, object id, object[] currentState, ...

Is the entity get cached in Query Caching?

I have used nhibernate for my implementation. There is a lot of database fetching involved and in order to reduce the processing time I enabled the query caching and loaded full table data on application on start. Then did linq against it. The secondary level caching and the query caching is enabled. It is working but when I do the proce...

Storing a double.MinValue with Nhibernate to sqlite.

Hello, I am using nhibernate for my OR persistence and I store a list of doubles into a table using the following mapping (where the list is embedded in another class). <list name="Values" access="field" table="Values_double" > <key column="variable_id"/> <index column="no_data_values_list_index"/> <element column="value" type="...

NHibernate + SqlCE - Forever Lazy?

I'm working on a Winforms app with NHibernate as my ORM layer. Everything is going well, but it doesn't seem that NHibernate is respecting my instructions to not use lazy loading. Problem 1: The app is a task list type of thing, and tasks can have child tasks. I'm representing these in a TreeView, so I need to first add nodes for top-l...

Working with NHibernate, ASP.NET MVC and Dropdown

We're using ASP.NET MVC together with NHibernate and we'd like to create several Dropdown Lists using Values (custom Class) from the Database. This actually works, but how do I handle the "Empty" value; I mean, the "unselected" DropdownValue? Something like "-- Select --" on the top of the List... Does anyone have experience with this co...

Can I use nHibernate with a legacy-database with no referential-integrity?

If I have a legacy database with no referential-integrity or keys and it uses stored procedures for all external access is there any point in using nHibernate to persist entities (object-graphs)? Plus, the SP's not only contain CRUD operations but business logic as well... I'm starting to think sticking with a custom ado.net DAL would ...

NHibernate disjunction resulting in AND queries instead of OR

Hi, This may be something obvious but I've been banging my head against it for a few hours and can't figure out where I'm going wrong. I'm trying to run a small piece of code to test adding OR criteria to an NHibernate query. This is the code I have: using (ISession session = NHibernateHelper.OpenSession()) { ICriteria criteria = ...

How to close a NHibernate connection?

Hello. I've done a site using ASP.NET MVC, NHibernate and MySQL. In my project, I have some repositories classes, each one with methods using codes like this: using(ISession session = NHibernateHelper.OpenSession()) { using(ITransaction transaction = session.BeginTransaction()) { session.Save(cidade); transaction.Commit();...

How to avoid a join using NHibernate 2.1 per table inheritance

I'm doing some per table inheritance and all is working great- but I'm noticing that when I want the base entity (base table data) NHProf is showing a left outter join on the child entity / (related table) How can I set the default behavior to only query the needed data - for example: When I want a list of parent elements (and only tha...

S#arp Architecture / NHibernate with multiple databases

I'm using S#arp Architecture (which uses NHibernate). I have some entities mapped to tables in one database and others mapped to a different database. Disclosure: Databases already exist so i can't do model first. How do I configure this to work? EDIT: Would the SchemaIs method in Fluent NHibernate be the recommended approach to map an...

NHibernate.ObjectDeletedException

I need some help figuring out how to proceed. I'm building an app to manage a record collection and i have the following mappings. <class name="Soulful.Core.Domain.Model.Record,Soulful.Core" table="Record"> <id name="Id" type="Int32" unsaved-value="0"> <generator class="native" /> </id> <many-to-one name="Artist" cl...

NHibernate and MySql is inserting and Selecting, not updating

Something strange is going on with NHibernate for me. I can select, and I can insert. But I can't do and update against MySql. Here is my domain class public class UserAccount { public virtual int Id { get; set; } public virtual string UserName { get; set; } public virtual string Password { get; set; } public virtual ...

Fluent NHibernate: subclasses inside subclasses

I have different kinds of products. Now, the AppProduct has different kinds of quantities - multiply of value, list of values, etc... public class Product : Entity { } public class Quantity: Entity { } public class ListQuantity : Quantity { public virtual IList<int> Quantities { get; set; } } public c...