nhibernate

S#arp architecture vs straight IOC + NHibernate + MVC

Are the benefits enough to use another external assembly? How difficult is it to remove S#arp and keep NHibernate at a later point? ...

How to build a mapping file for an insert stored procedure using NHibernate 2.1

I'm looking for a way to map a simple insert stored procedure using NHibernate 2.1 Most of the examples I find are for getting data back from a sproc - but what I'm trying to do is insert an audit like record using a stored procedure. But I would prefer to build a mapping file for this Also - to be clear I'm not looking to build an en...

Problem with delete operation in many to many relation

Hi, I've got to classes Product and Store which have many to many relation I want deleting of store not to cause deleting of related product And deleting of product not to cause deleting of related store. Currently deleting of entity cause exception due to Foreign Key constraint. Here is this classes and their mapping in fluent hiber...

Checking existence of lazy loaded child without getting/loading in Fluent NHibernate

This should be easy, but I can't seem to figure it out... How can I check if a child on an entity exists without actually getting or fetching it? The child is lazy loaded right now.. so I have two entities: class A { public virtual int Id { get; set; } public virtual B Child { get; set; } } class B { public virtual int Id ...

Nhibernate bag is not saved

Hello, I'm trying to save an object that contains a bag with a many to many relationship. The problem is that the object is saved correctly but the bag isn't. Here is my mapping, can anyone tell me what I'm doing wrong. Thanks <class name="XManager.Business.Afspraak, XManager.Business" table="Afspraak" lazy="false" mutable="false"> <...

Extensible domain model with NHibernate

I'm currently designing solution where the domain model & the repository can be extended by application plugins. Now, i have come across a few issues that i am listing below. My first issue is making domain model extensible. I was thinking about using inheritance here, but honestly, i have no idea how i can leverage multiple plugin ass...

Add Interceptors through the web.config? NHibernate

I can't seem to find an example where someone added an interceptor via web.config - is this possible? And yes I know about event listeners and will be using them on another project - but I wanted to see if I could get around having to inject the interceptor in code - thank you ...

Nhibernate - Mapping List doesn't update List indexes

Hi, I'm having one self-referencing class. A child has a reference to its parent and a parent has a list of children. Since the list of children is ordered, I'm trying to map the relation using NHibernate's . This is my mapping: <class name="MyClass"> <id name="Id"> <generator class="native"/> </id> <list name="Children" cas...

Fluent NHibernate HasManyToMany() Mapping Problem

Hi, i am having a problem in Fluent NHibernate example utilizing the Many-to-Many relationships, i tried to find out examples on a similar case, and i found tons , but still having the same problem. when run the test project the following exception is thrown: NHibernate.PropertyAccessException: Exception occurred getter of project.Enti...

Cascading in (N)Hibernate, which rules do I need?

Sorry if this is a dupe, couldn't find it but didnt really know what to search for, anyway... I have three classes, Parent, Child and Other Parent has many Child where child has a Parent_Id column Other holds a reference to a Child through a Child_Id column When I delete a Parent, I also want to delete all the associated Child object...

Register custom NHibernate Interceptor via Windsor

I created a simple AuditInterceptor: EmptyInterceptor now I wonder how can I register this new interceptor with my application using Windsor? ...

How can one delete an entity in nhibernate having only its id and type?

Dear ladies and sirs. I am wondering how can one delete an entity having just its ID and type (as in mapping) using NHibernate? Thanks. P.S. I use NHibernate 2.1 ...

How to handle transactions between several generic IRepositories

What is a good practice on work with (nHibernate) ITransactions between several repositories? First created a BeginTransaction() on the generic interface, but i then come to think about how will this work between the repositories? i mean if a delete things from on repository and then other things from another repository, but want's to w...

nHibernate ICriteria Join Condition

I am trying to use ICriteria to create a query that has a join condition. The SQL I am trying to generate should look like this SELECT c.ClientID FROM Client c LEFT OUTER JOIN ClientContact t on c.ClientID = t.ClientID AND t.ContactType = 'Email' If I use a criteria like m_ClientRepository.QueryAlias("client") .CreateCriteria("c...

How can one delete NHibernate objects using a criteria?

Dear ladies and sirs. This must be a simple question. Given a criteria, how one deletes the entities satisfying the criteria? The rationale: HQL and NH criteria are NHibernate specific constructs and as such they are server side DAL implementation details. I do not want them to "leak" to the client side. So, our client side provides ...

Does anyone know how to translate LINQ Expression to NHibernate HQL statement?

Dear ladies and sirs. Does anyone know of an existing solution to translate a LINQ Expression to HQL statement? Thanks in advance to all the good samaritans out there. P.S. We already use Linq to NHibernate. However, it only works for select statements, whereas HQL is good for other statement kinds, like delete. So, Linq to NHibernat...

Struggling to map a relationship with NHibernate

I'm working with 2 tables, Employees and a table called EmployeeGroups as follows. I've left out most of the unrelevant columns below. I'm struggling to map the foreign key relationship. Its a one-to-one relationship where not every EmployeeId in the Employees table will exist in the EmployeeGroups table. I'm wondering how to setup the E...

nHibernate Composite Key Class Type Mismatch

I have a legacy table with composite keys that are mapped to 3 other tables, since this table have other attributes in it, since it is not a simple mapping table, I can't use the many-to-many set solution to map this. The following is what I have done: <class name="classA" table="A"> <composite-id name="ID" class="AKey"> <key-many-to...

NHibernate Criteria Collection Contains

I have a parent/child relationship mapped with a many-to-many set. public class Parent { public ISet<Child> Children { get; set; } } public class Child {} public class ParentMap : ClassMap<Parent> { HasManyToMany(x => x.Children) .AsSet(); } How can I write a query to select all of the parents that contain a given ch...

NHibernate, validation logic and AutoDirtyCheck

Here is my scenario: I'm using nhibernate, openning and closing the session in an IHttpModule (PreRequestHandlerExecute and PostRequestHandlerExecute). Ninject takes care of injecting my session in all my repositories and I'm very happy with it. Now suppose an Update to one of my entities (code simplified): Controller: User user = _...