nhibernate

Execute custom sql for one property in NHibernate

As I understand it NHibernate has a build in support for timestamps. However, it appears you can only instruct NHibernate to never update the property or always update it. In the project I am currently working on there are several tables which have both "created_time" and "updated_time", both are to be generated by the database. I can...

Is it possible to eager load over two one-to-many relationships in NHibernate?

Given an object hierarchy such as the following: class Category { List<SubCategory> SubCategories; } class SubCategory { List<Product> Products; } class Product { } Is it possible to eager load the whole hierarchy using NHibernate? I would like to execute one query to load all categories with subcategories and products eager...

Querying on collection of strings with NHibernate

Hi, I have an "Item" class, and this class has a collection "Tags". Item IList<string> Tags; my DB looks like this: Items Id Tags ItemId TagName I am trying to get all Items which have the tags "x" and "y". How can I do this with NHibernate (preferably with criteria API)? Is it even possible? Thanks. EDIT: can I do...

NHibernate, SchemaExport, how to name fk constraint on one to many?

I am using NHibernate and using SchemaExport to generate my entities. I have an entity with one to many relation ship and would like to name the foreign key constraint. I have this article as a references but it talks about a many to one. When I put use the Foreign-key attibute on the 'key' element, I get a error that says the table al...

Inheritance Mapping with Fluent NHibernate

Given the following scenario, I want map the type hierarchy to the database schema using Fluent NHibernate. I am using NHibernate 2.0 Type Hierarchy public abstract class Item { public virtual int ItemId { get; set; } public virtual string ItemType { get; set; } public virtual string FieldA { get; set; } } public abstra...

NHibernate fetch="join" mapping attribute does not appear to work

Mapping a dictionary with NH. Declaration is as follows: <hibernate-mapping ... <map name="CostsByRole" table="JobAccountingSnapshotCosts" lazy="false" fetch="join" access="nosetter.camelcase-underscore"> <key column="SnapshotId" /> <index column="RoleCode" type="String" /> <element col...

NHibernate O/R Question

I have written a lot of ejb, oledb and ADO code over the years. My experience with O/R mappers is at best they are pigs for speed, at worst a bug filled nightmare. Is NHibernate or Spring .NET worth the trouble and why? ...

Query Unmapped Columns in NHibernate

I have a class that is mapped to a table using NHibernate. The problem is that only some of the properties are mapped to columns in the table. This is fine because the only columns we use for display are mapped, however I was wondering if there is any way to query against other columns in the table that aren't mapped to properties in my ...

Nhibernate with Microsoft System.Data.OracleClient

I am trying to use Nhibernate with Oracle using Microsoft's System.Data.OracleClient Nhibernate Configuration (Is it correct for Microsoft Driver ?) <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="show_sql">true</property> <property name="connection.provider">NHiber...

Is Linq to NHibernate in the 2.1 Alpha release?

So the nHibernate 2.1 Alpha came out a few days ago, but the announcement on sourceforge doesn't mention the additional features. In particular, it doesn't mention whether LINQ is included. I know that I've read that LINQ would be part of 2.1, but that was 6 months ago. Anybody know if LINQ is in 2.1 or what new features are? There's no ...

What differentiates Nhibernate from other ORM’s?

Apart from the fact that it’s open source and mature, what are the differentiating factors that separate nhibernate from rest of the .net ORM frameworks like Subsonic, ADO.NET Entity Framework etc? Better put, why should I choose nhibernate over other .net entity frameworks? ...

What is a good reverse db engineer tool for NHibernate?

Does anyone know of a good tool to reverse engineer mappings and business classes for NHibernate? NHibernate is best for greenfield development, but we also need to work with large legacy databases. I've tried NGen, which does ok, but it does the entire DB and you cannot select individual tables or map to sprocs and it maps a UNIQUEIDENT...

NHibernate mapping generic classes

How does one create a mapping file for a generic class in NHibernate. Say I have a class Foo How would it look in the mapping document? class name="mydll.Foo ???? , mydll" ... I know if it was a Foo it would be: class name="mydll.Foo`1[[mydll.Fee, mydll]], mydll" Would it be something like: class name="mydll.Foo`1[[mydll.Fee, mydll],[m...

Using Unmapped Class with NHibernate Named Query

I'm using a custom named query with NHibernate which I want to return a collection of Person objects. The Person object is not mapped with an NHibernate mapping which means I'm getting the following exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. It's getting thrown w...

Entity Framework vs alternatives

Duplicate: What ORM frameworks for .NET Do You Like Best? What are you currently using for data access? When choosing an ORM, is LINQ to SQL or LINQ to Entities better than NHibernate? Database (and ORM) choice for an small-medium size .NET Application Etc. What OR\M would you recommend for a large ASP.NET application, Entity Framew...

duplicate object graph and persist back as new in nhibernate

I want to create "previous versions" so a user can undo changes made and roll back to a previous version. I've got a manager object with various properties and a collection of managed staff. this relates to two tables in the database with staff linked to the manager by a foreign key. What i'd like to do is duplicate the manager and a...

Get started with nhibernate

Hello Everyone, can you suggest me any sources where they could explain using nhibernate for dummies? I don't even know which version to download or visual studio 2008 and where? and how to use it after download, where to put dll files and stuff? thanks a lot for your help ...

NHibernate Single Table Inheritance

I'm having trouble setting up a role based structure using inheritance and NHibernate. Basically I would like to have an abstract class called ObjectInRole. This class (and corresponding database table) contains a RoleId, an ObjectId, and an ObjectType (this would be the discriminator column). The discriminator column would be the obj...

Linq to entity with a big database

We are about to start a project which involves using a Sql Server 2005 with lakhs of records. In the past I have used NHibernate with good results. But now I am evaluating Linq to entity for the data access. I have these questions on L2E, How good is the caching that the L2E does compared to NHibernate (basically how is the performanc...

Sequential GUID in Linq-to-Sql?

I just read a blog post about NHibernate's ability to create a GUID from the system time (Guid.Comb), thus avoiding a good amount of database fragmentation. You could call it the client-side equivalent to the SQL Server Sequential ID. Is there a way I could use a similar strategy in my Linq-to-Sql project (by generating the Guid in code...