nhibernate

NHibernate one-to-many delete

I am working on an ASP.NET MVC application using NHibernate as the ORM. I have two domain objects: public class Contact { public int ID { get; set } public string Name { get;set; } public IList<ContactNumber> ContactNumbers { get; set; } } public class ContactNumber { p...

Hibernate configure how to create an object

Is it possible to configure Hiberate/NHibernate not to use the default constructor to create objects when reading from the database? When Hibernate reads 10 customers from a table, it creates 10 Customer objects. It does this by Customer c = new Customer(); Can I tell Hibernate to do the following instead: Customer c = ACertainStati...

Need help for my NHibernate mappings

Hello all, I have the following (simplified) mappings: public class RosterMap : ClassMap<Roster> { public RosterMap() { References(tr => tr.Team) .Not.Nullable(); HasMany(r => r.Players) .Inverse() .Cascade.AllDeleteOrphan(); References(roster => roster.Match) ...

Using part of a composite primary key in a composite foreign key in NHibernate

We have a fairly big DB (~200 tables) which almost entirely uses composite primary keys and composite foreign keys, using a single "base table" from which every other table inherits part of its primary key: Parent has single column primary key ParentId Child has composite primary key (ParentId, ChildId) and foreign key ParentId Nephew ...

Stored procedure in nHibernate?

Is it possible to CREATE (not query) a stored procedure with nhibernate? ...

Populate DTO from several queries

I have a DTO with 40+ properties. But in order to populate all properties I need to execute 4 separate queries. My first query is in charged of getting basic information. For each row returned I run 3 more queries based on the id's given from the main query (N+1 problem). I can set use eager loading but then I'm loading thousands of obje...

How to test NHibernate apps: four specific items to test

From NHibernate Unit Testing: When testing NHibernate apps I usually test several things: a) that I have correctly created the mapping b) that I mapped all the persistent properties c) that I have correctly defined cascades And most importantly, that my queries return the correct results. That is the most ...

NUnit AreEqual always returns false.

I'm sure I missing something simple here but I can't figure out why my NUnit object comparison test continues to fail. I have a simple object: public virtual int Id { get; private set; } public virtual string Description { get; set; } public virtual string Address { get; set; } public virtual string Ports { get; set; } ...

change the constraint name in fluentNhibernate auto mapping alteration

i'm using oracle with FluentNHibernate automapping with alterations & NHibernate the problem is how to specify the constraint name by overriding the mapping model?? the generated sql like this: alter table FirstTable add constraint FK_VerLongIdentifierLongerThan30Characther foreign key (FirstTableID) references SecondTable...

What is the last version of nhibernate that supports .Net Framework 2 ?

Hello, What is the last version of nhibernate that supports .Net Framework 2 ? and is there a big difference between dealing with it and dealing with last version that supports .Net 3.5 ? ...

NHibernate: Composite key many-to-one mapping: Can't resolve property (foreign key component)

Hi guys, I hope anyone can help. I have to develop up against this third party database and I am kind of stuck with their crappy design. Still, I want to use NHibernate so I will have to jump through hoops. Simplified, there is this "Event" table that has a relation a "Transportation" table. The transportation table has a composite p...

Auxiliary Database Objects with Castle ActiveRecord

I know it's possible to run extra DDL scripts with NHibernate. For example triggers or indexes. This feature is NHibernate is named "Auxiliary Database Objects". Is it possible to do same thing in Castle ActiveRecord? ...

NHibernate QueryOver with ManytoMany

I'm in the process of learning QueryOver, but I can't for my life figure out how to do simple many to many queries. I've written the following: var result = Session.CreateCriteria(typeof (Product)) .CreateAlias("Categories", "categories") .Add(Property.ForName("categories.Id").Eq(categoryId))...

NHibernate - Why doesn't NHibernate insert child entities in one-to-many?

Hello.. In my example I have Servers and those Servers belong to a ServerGroup. I am populating a ServerGroup with Servers and saving the ServerGroup. The ServerGroup table is populated but the Servers are not. public ServerGroupMap() { Id(x => x.Id); Map(x => x.Name); HasMany(x => x.ServersInGroup) ...

Why is Fluent NHibernate ignoring my unique constraint on a component?

In my map I have: Component( x => x.ExposureKey, m => { m.Map(x => x.AsOfDate).Not.Nullable(); m.Map(x => x.ExposureId).Length(30).Not.Nullable(); } ).Unique(); The relevant output from the HBM is <component name="ExposureKey" insert="true" update="true" optimistic-lock="true" class="Some.Namespace.CreditE...

S#arp Architecture - Rhino Security (unmapped class: Rhino.Security.IUser)

Hi, I'm using S#arp Architecture 1.6 and have implemented the Rhino Security integration as per Rhino Security - S#arp Architecture I'm using the latest build from Rhino.Commons My Application_EndRequest method contains ISession session = NHibernateSession.Current; My ComponentRegister.cs contains container.Kernel.Regis...

self-reflexive n:m relation using composite keys in nhibernate

I have a legacy database with 3 tables like this: The Items table contains all the Items in a Plan. The Structure table defines the relation between the items. A parent item is defined by company, year, planId and parentItem of table structure mapping to company, year, planId and id of table item. A child item is defined by company, yea...

Could not load an entity in NHibernate then Timeout Exception when Table is existing

I need help on this. I got this error while inserting/updating a number of records could not load an entity: [Star.CNPL_BusinessObjects.Entities.CNPL.CNPL_AgencyProduct#48][SQL: SELECT cnpl_agenc0_.Id as Id48_0_, cnpl_agenc0_.AgencyID as AgencyID48_0_, cnpl_agenc0_.ProductID as ProductID48_0_, cnpl_agenc0_.CreatedDate as CreatedD4_48_...

nhibernate - sproutcore : How to only retrieve reference ID's and not load the reference/relation ?

Hi All, I use as a front-end sproutcore, and as back-end an nhibernate driven openrasta REST solution. In sproutcore, references are actualy ID's / guid's. So an Address entity in the Sproutcore model could be: // sproutcore code App.Address = App.Base.extend( street: SC.Record.attr(String, { defaultValue: "" }), houseNumber: SC.R...

NHibernate Criteria API - order by max of two properties

Hi, I have a PrivateMessage class and I want to get list of PMs for user sorted chronologically either by CreationDate or LastAnswerDate (depending on which is more recent) using Criteria API. How to sort by max of these two properies in Criteria API? My code looks similar to following: var dc = DetachedCriteria.For<PrivateMessage>(); ...