nhibernate

Can I write this SQL using Criteria API?

I am trying to reproduce this query in Criteria API. In my mappings I have a many to many between Tag and Product, but this only appears in my Tag class, i.e. the Product class has no knowledge of tags. Basically I want to find all the products that have all of a list of tags. Here is the sql I produced although it is probably possible t...

Using NHibernate/FluentHibernates save with table as parameter.

I have a collection of Answer's (IList<Answer>) and two tables(Answer and AnswerHist). I want to do something along the lines of: Get the current answers from db. save(Answers, "AnswerHist"); delete(Answers, "Answer"); Answers = questions .Select(x => new Answer(response) { ...

NHibernate - What kind of association(s) is this?

I'm having some trouble getting NH to persist my object graph. I have (something like) this: /*Tables*/ TABLE Parent ParentID PK LastEventID NULL TABLE Event EventID PK ParentID FK NOT NULL //Model Classes public class Parent { public List<Event> Events; //Inverse //Denormalized bit public Event LastEvent; ...

Which ORM tool should I use for .Net development

My company is looking to use an ORM for new development in .Net. We are currently looking at nHibernate, because of its popularity, however LLBLGen is another option that we may consider. Cost is not a primary factor. We need a solution that provides good separation of the domain model from the database, a good caching strategy, developm...

NHibernate - not-null property reference a null or transient value

I'm getting this exception (Full exception at the bottom): NHibernate.PropertyValueException was unhandled by user code Message="not-null property references a null or transient valueClearwave.Models.Encounters.Insurance.Patient" Source="NHibernate" EntityName="Clearwave.Models.Encounters.Insurance" PropertyName="Patient" I've don...

Limiting number of results when using NHibernate

Hello, I was wondering how people usually go about limiting the number of entities returned from a query. I know about SetMaxResults but this seems to break down as soon as joins are involved - 3 entities with each 2 children will produce 6 rows as a result. If I use SetMaxResults(3) to get only 3 entities I will only get 3 resulting ro...

Organization Id Field as a Composite Primary Key

We currently have a system where each client gets their own database when they sign-up. Not surprisingly this is getting out of hand. We are preparing merge all these databases together to a single db. In order to do this we need to note which organization the row belongs. How best is this handled on the database and what pros/cons (...

NHibernate mapping to insert/select record based on unique non-primary key

I have these tables: create table Brand ( ID int identity(1,1), Name varchar(100) not null unique, primary key clustered (ID) ) create table Product ( ID int identity(1,1), Name varchar(100) not null, BrandID int not null references Brand(ID) ) I have the respective entities in c#, namely the Brand entity has a...

In NHibernate, can I use factory to build complex aggregate object (Entity)?

In NHibernate, can I use factory to build complex aggregate object (Entity)? If yes then how? If not.. then what is your approach? ...

Are Denormalized Updates Possible With NHibernate Without Using a Stored Procedure?

I'm pondering the use of NHibernate on a project that has a database with some degree of planned denormalization (planned by the DBAs). Reading from one set of tables and mapping one column to one property is not a problem. However when updating I'd have to map one property back to the original column in the original table plus update a ...

WCF OperationContract and Nhibernate ICriteria

We are trying to create a cool API using WCF and ICriteria, for example: [ServiceContract] public class ProductService { [OperationContract] public List<Product> Get() [OperationContract] public List<Product> GetByCriteria(Criteria criteria) } We are thinking of using the DetachedCriteria so anyone can send it and we connect this to...

Returning NHibernate mapping classes from WCF services

I have a server that handles the database access and a client that consumes the information. The communication from the client to the server is through a WCF service. When the NHibernate POCO is returned from the service are all the objects in the object graph serialized? If so, is there a way to change it? I'm also thinking of not ret...

sql profiler shows nhibernate running queries twice?

Hi All, I have been doing some performance analysis on an application I am working on. The application is web-based (asp.net) using an old version of NHibernate (1.0) on MSSQL Server (2005). Running profiler against the application seems to show something a little odd, in that we seem to be querying objects twice, once as a direct que...

Implementing NHibernate DetachedCriteria-like

I would like to write something like DetachedCriteria but I don't want to use the ISession or Nhibernate at all... All I need is the implementations for ICriterion and Expression. after writing such Criteria -> I would like to generate an Xml Query or AD-Query or maybe even Query on collection (something like the Linq2Objects) Do you ...

Hibernate Next/Previous Sibling Mapping

I'm using nHibernate to map an object very similar to .NET's System.Web.SiteMapNode. In order to keep my object similar to this .NET object I would like to have it contain a ParentNode, PreviousSibling, NextSibling, and ChildNodes complex properties. The table looks somewhat like this and is open to be changed: ID (int) Title (string...

one-to-one fluent nhibernate?

Is it possible yet to do a one-to-one mapping with fluent nhibernate? I have the following as part of an hbm that I'm trying to convert to fluent: <one-to-one name="Person" property-ref="FileData" constrained="true"/> I see a OneToOnePart<OTHER> in the code but i'm not sure how or if this is used to accomplish this. Thanks! ...

Unmapped Columns in NHibernate?

I'm working with a legacy database in Oracle and some of my tables have columns that are set to NOT-NULL that I don't want in my domain model, but, obviously, I need to specify somewhere that at least some default value is saved to the database (eg a Groups table may have a "Indentation" column thaqt always expects a char(8) value). How...

How do i get the the full name of the proxyed type for a nhibernate DynamicProxy?

I am using a netdatacontractserializer and a SerializationBinder to create my own runtime types for nhibernate proxies on the client side. This all works except I am forced to assume that there is only one type by each name in the domain model. i.e. i am forced to ignore the namespace. The reason is that SerializationBinder only gives m...

fluent nhibernate select n+1 problem

I have a fairly deep object graph (5-6 nodes), and as I traverse portions of it NHProf is telling me I've got a "Select N+1" problem (which I do). The two solutions I'm aware of are Eager load children Break apart my object graph (and eager load) I don't really want to do either of these (although I may break the graph apart later ...

NHibernate/Fluent NHib: How to use UserTypes for Ids?

I have columns in my Oracle db that I use a TrimmedStringUserType for to trim text from char(x) columns. The db has natural keys in many tables, so I'm using Assigned Ids. Many of these are char(x) columns. How, using Fluent NHibernate (or even in the xml mapping) would I use this usertype to ensure that the Ids are trimmed? ...