nhibernate

Single website multiple connection strings using asp mvc 2 and nhibernate

Hi In my website i use ASP MVC 2 + Fluent NHibernate as orm, StructureMap for IoC container. There are several databases with identical metadata(and so entities and mappings are the same). On LogOn page user fiils in login, password, rememberme and chooses his server from dropdownlist (in fact he chooses database). Web.config contains...

nhibernate : how to query collection inside parent entity

I have the following method. This works fine if i remove the following line .Add(Restrictions.Eq("Product.IsPopItem", true)) The error message is could not resolve property: Product.IsPopItem of: EStore.Domain.Model.ProductCategory I'm confident the "Product.IsPopItem" is mapped correctly as i can call this property. Do i need to ad...

How to debug Fluent nHibernate

Hi, I'm having some trouble with Fluent nHibernate. I added a column to a table and I thought I'd correctly changed the mappings and the connected data objects to correctly reflect this. However when I tried to run my application again I kept getting this error: System.Data.SqlClient.SqlException: Invalid column name 'Workflow_id'. I...

Does Nhibernate support Sybase?

I'm about to start on a new WPF application with a Sybase datastore. The team has experience with Nhibernate, but we are not really sure how well it supports Sybase and if there are some major pitfalls we should look out for. If yes, how about Fluent nhibernate? If not, do you know any other ORM products that we could use for Sybase i...

NHibernate mapping with no empty constructor and no setters

I'm testing how difficult it is to use NHibernate with a domain that is completely unaware of it and isn't bent to accodomate any limitations. On many examples I found on the web the domain being mapped is yet another example of an anemic domain, where objects don't go far from being simple data holders. Sure, this makes the mapping sim...

Fluent NHibernate - Mapping a dictionary of component/value type objects as a HasMany

I have a class, Item that has many Rates. They are keyed by an enum, RateType. public class Item { int Id {get;set;} IDictionary<RateType, Rate> Rates {get;set;} // some other stuff } public class Rate { RateType Type {get;set;} decimal Amount {get;set;} decimal Quantity {get;set;} } I am overriding my mappin...

HQL over ternary map with subcollection

I'm stuck with a query I need to write. Given the following model: public class A : Entity<Guid> { public virtual IDictionary<B, C> C { get; set; } } public class B : Entity<Guid> { } public class C : Entity<Guid> { public virtual int Data1 { get; set; } public virtual ICollection<D> D { get; set; } } public class D : En...

Nhibernate: Stop it from joining to a table that is not needed

I have two tables (tbArea, tbPost) that relate to the following classes. class Area { int ID string Name ... } class Post { int ID string Title Area Area ... } These two classes map up with Fluent Nhibernate. Below is the post mapping. public class PostMapping : ClassMap<Post> { public PostMapping() ...

Loading a entity IDs CSV column as hydrated entities in NHibernate

I have a number of database table that looks like this: EntityId int : 1 Countries1: "1,2,3,4,5" Countries2: "7,9,10,22" I would like to have NHibernate load the Country entities identifed as 1,2,3,4,5,7,9 etc. whenever my EntityId is loaded. The reason for this is that we want to avoid a proliferation of joins, as there are scores o...

IQueryable Where fails to work

I am using N-Hibernate and have a class/table called Boxers I also have a prospect table which tells use if the boxer is a prospect. (this table is one column of just the boxersID) So i Want to get all boxers that are prospects (meaning all boxers that have there id in the prospects table) Public static IQueryable<Boxer> IsProspect(th...

IStatelessSession insert object with many-to-one

Hello guys. I've got common mapping <class name="NotSyncPrice, Portal.Core" table='Not_sync_price'> <id name="Id" unsaved-value="0"> <column name="id" not-null="true"/> <generator class="native"/> </id> <many-to-one name="City" class="Clients.Core.Domains.City, Clients.Core" column="city_id" cascade="none"></many-to-one...

How to remove the NHibernateMessageModule from being called in NServiceBus?

I am not using the nhibernate saga persistence and hence I do not need the NHibernateMessageModule. So how do i remove it? ...

Fluent nHibernate - How to map a non-key column on a junction table?

Taking an example that is provided on the Fluent nHibernate website, I need to extend it slightly: I need to add a 'Quantity' column to the StoreProduct table. How would I map this using nHibernate? An example mapping is provided for the given scenario above, but I'm not sure how I would get the Quantity column to map to a property o...

NHibernate HiLo Intervention

We have a single server/single database application that uses NHibernate and Castle ActiveRecord, SQL Server sits behind it. As part of the processing I need to write as many as 1.2 million rows of data. Using ActiveRecord and NHibernate is woefully slow and needs to be improved - this could easily be done with an "insert into .. select...

HQL query over sub-classes

I have the following entities defined in my Entity Model: public class MyContainer { public virtual ICollection<Base> Subs { get; set; } } public abstract class Base { public virtual Guid Id { get; set; } } public abstract class Sub1 : Base { public virtual int MyValue { get; set; } } public abstract class Sub2 : Base { pub...

Anyone know of any decent resources on Stored Procedures for Fluent Nhibernate 1.1

A recent release of Fluent Nhibernate (1.1) now supports stored procedures. I was wondering if anyone out there has found any good blog articles on how to do this! I am not asking about using classic hbm mappings instead which these questions previously asked: http://stackoverflow.com/questions/296732/does-fluent-nhibernate-support-map...

Roll back changes to object if invalid

How do i roll back changes to an attached object in nhibernate? We have a validation before update/save (example simplified).. var setting = Get("key") setting.Value = "helo" //for whatever reason, this particular //setting cannot have its value saved to the database ... Verify(setting); //throws base.Updat...

Insert using stored procedure from nhibernate

Hi I am using the following code snippets to insert values using stored procedure. the code is executing successfully but no record is inserted in DB. Please suggest with simple example. **---- stored procedure--------** Create PROCEDURE [dbo].[SampleInsert] @id int, @name varchar(50) AS BEGIN insert into test (id, name) val...

NHibernate Bi-directional ManyToMany Relationship Caching Issue

I got issue with bi-directional ManyToMany relationship caching First side mapping : HasManyToMany(x => x.Jobs) .Table("ProfileSuggestStoryJob") .AsSet() .Cascade.None() .ParentKeyColumn("ProfileSuggestStoryId") .ChildKeyColumn("JobId") .Cache.ReadWrite(); ...

[N]Hibernate: view-like fetching properties of associated class

(Felt quite helpless in formulating an appropriate title...) Is it possible to define a mapping for a class such that some properties are fetched from another table using a join query? In my C# app I display a list of "A" objects, along with some properties of their associated "B" objects and properties of B's associated "C" objects: ...