nhibernate

What's your opinion of Castle ActiveRecord?

I need a .Net ORM, and I heard some good things about this. I've had NHibernate running in the past, but this seems to make a lot of things easier. However, two things made me a little nervous. It uses NHibernate 1.2, which seems old It's still an RC with its last release 18 months ago Is anyone using it, and do they recommend it f...

How do you manage your ORM layer when database undergoes changes ?

I understand the reason behind not auto refreshing your .dbml (Linq2Sql), .edmx (Linq2Entities) or .hbm.xml (NHibernate). In each of these ORM solutions you need to update these files if you have changes in the database. Is there a way to refresh these files automatically if you are 100% sure that it wont break anything? I am reasonably...

NHibernate AddOrder on related entity property

I have a search form and result list. The form allows the user to search on the entity properties and related entity properties. NameContains EmailContains CompanyNameContains The result list displays the contact properties and the relevant related properties, in this case company name Name | Phone | Email | Company Company is a r...

CreateCriteria and MONTH

Hello! Is it possible to use MONTH in a CreateCriteria-statement? Does NHibernate support YEAR and/or MONTH? I have a sql-statement like select obs2.Lopnr from Obs obs2 where MONTH(obs2.Datum)=11) Best Regards from Mats ...

Multiple simultaneous saves cause WCF/NHibernate "Row updated by another transaction"

I am working on a large application that manages complex 'events' with quite a bit of data. The application is broken into a client (C# mainly .NET 2.0 mainly), a WCF based server made to run on IIS (web services at this layer), and a data back end that is NHibernate based with an MS SQL Server database backend. We are encountering a b...

NHibernate: Using Fluent Nhibernate to save child objects

Hello, In my system, I have two entities - ShoppingCart and ShoppingCartItem. Fairly generic use-case. However, when I save my ShoppingCart, none of the items are being saved to the DB. Within my object, I create a new ShoppingCart object. ShoppingCart cart = CreateOrGetCart(); I then add an existing Product which I got from the data...

Mapping one to many collection with Foreign Key to Foreign key

I'm mapping a legacy database with nhibernate and having some problems with mapping a realation. The two classes look like this public class Questionnaire { public int Id {get; set;} public string FormCode {get; set;} public IList<Question> Questions {get; set;} } public class Question { public int Id{get; set;} pu...

HQL "Contains" statement howto?

Hi, I have an entity that has a string property called Tags. I would like to query this entity based upon if a certain string is located in Tags property. So for example, I would have a function IList GetEntityByTag(string tag), this would return all Entity's that have the value of tag in their 'Tags' property. I tried going through t...

How to use NHibernate in distributed architecture?

I start build a system with distributed architecture by all applications will communication by REST service to expose some data(DTO) or invoke some updates. I would like to know how to use NHibernate to help with manage domain object because they are in different applications. How NHibernate identify which objects are new for inserting a...

Hibernate/NHibernate mapping file editor

I'm looking for an editor that has the help from http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html built in, and allows simple editing of the XML files in a GUI fashion. I realise there's CodeSmith and MyGeneration, but from what I remember these only go one way, and don't allow editing existing HBM files. ...

NHibernate one way, one-to-many, mapping question

Hi, I have a scenario in NHibernate where I have a one-to-many relationship between entities Employee and EmployeeStatus. Employee has properties eg: ID, Name and an IList of EmployeeStatus, whilst EmployeeStatus, for the purposes of this question, just has it's own ID and some free text. I don't need to hold a reference to Employee f...

Linq + NHibernate: is it production ready?

Is Linq + NHibernate production ready? I hear many folks using it in production code but it is still officialy 'Alpha'. It has been a long time, however, so what's your experience? ...

NHibernate and Collection Counts

I have the following class setup for persistence using NHibernate public class Person { public string Name { get; set; } public IList<Person> Subordinates { get; set; } } Now say I have a grid with two columns, "Name" and "Number of Subordinates" what is the best way of doing this in NHibernate whilst retaining the use of doma...

NHibernate: retrieve current database server DateTime

Hi, How could I get the current DateTime from the database server, using NHibernate? I tried to use the current_date expression, but it doesn't seem to work outside the where clause. What I need is something like SELECT getdate(). This query in SQL server gets de current datetime from the server, I just don't know how to put it in HQL d...

Querying on Collection with Nhibernate Criteria Api ?

Hi, I have an "Estate" entity, and this entity has a collection "EstateFeatures"(type:EstateFeature) and EstateFeature has a property "MyFeatureValue". Note: These are the limited properties for the question. All Entities has an Id and all necesarry etc Estate IList<EstateFeature> EstateFeatures; EstateFeature FeatureValue MyFeat...

SetForceCacheRefresh?

How do I re-read some (class) Items from the database? I have read them once and made same updates, updates I dont wont to save. Now I need a complete fresh collection of Items from the database. I have noticed that there are a function called SetForceCacheRefresh, but how do I use it with a CreateCriteria? // Mats ...

NHibernate - Mapping ID to a DB2 Identity

I'm newish to NHibernate, and am attempting to wire up to a DB2 table through the ISeries provider. The table has a BIGINT primary key that is auto generated as an identity. I've tried several values for the generator property of the id in my mapping file, and haven't had any success. The table def looks like so (field names changed):...

Updating a collection to db

Hi, This may be a little naive but I just want check my way of doing this is correct. I receive a collection of objects from the UI. I then wish to check those objects against the records in the db. This is what I am doing to Create Update and Delete the received objects. Loop trough received objects - if (id == 0 ) create new record...

.NET ORMs - What advantage does NHibernate (or SubSonic or whatever) give over using Entity Framework?

I'm wondering, what are the main reasons for not to use the built-in Entity Framework? I've read that it's disliked because of its bad implementation, but is this all? And is it still true? (I don't remember the publish date of the article) I know there exist a lot of options, but why should I consider switching? I only have a little e...

How to return first object of a collection from its parent

I am looking to do the following with a single database query if possible. public class Location { public string URL {get;set;} public IList<Page> Pages {get;set;} } Page firstPage = Session.Linq<Location>() .Where(location => location.URL == "some-location-url") .Select(location => location.Pages).FirstOrDefault(...