nhibernate

Does nHibernate allow drag and drop automatic class creation like linq to sql?

Just a basic question. Learning Linq to SQL and some nHibernate. I am using the mvc tutorial and they drag and drop tables onto the visual studio designer to create the classes and wire up everything. When I experimented with nHibernate I had to do lots with xml files. Does nHibernate have anything that is "easy" like Linq to SQL o...

How do I output the HBMs that Fluent NHibernate Creates?

I am debugging my fluent application and would like to see what the generated files look like. Can someone help me out? -Nick ...

Fluent Nhibernate Generates Invalid column names in One-to-Many

Hello.. Fluent NHibernate Generates invalid columns names within a Many to one relationship. enter public EmployeeMap() { Id(x => x.EmployeeID); Map(x => x.FirstName); Map(x => x.LastName); Map(x => x.City); Map(x => x.HireDate); Map(x => x.Title); HasMany(x => x.Orders) ...

Hibernate/NHibernate : how to persist subclass as instance of superclass

I have two classes I would like to persist via NHibernate: - Cat, which has a name and an Id, - Kitten, which is a subclass of Cat (no extra public properties). For stupid reasons, I would like to know if it is possible to map Cat only? So that when I persist Kitten, it is saved as a Cat and when I reload it, it is loaded as a Cat. Add...

Executing Sql statements with Fluent NHibernate

Basically I want to be able to do this: session.ExecuteSql("..."); I don't need it to map to any entities or return any values. Any suggestions? ...

NHibernate multiple primary keys mapping

I have a table called "Orderrow". Orderrow has a a compound primary key (CPK) with the following columns: OrderId, ProductId, RowNumber OrderId and ProductId are also foreign keys refering to the tables Order and Product. The RowNumber is generated in the app. I was wondering how this is mapped in NHibernate because I can only set 1 id...

Parsing NHibernate exception text

I'm trying to get NHibernate to load some records for me (it's been partially set up, and is used for some other parts of the app already), and while working on an <any> mapping, I got this exception: [InvalidOperationException: any types do not have a unique referenced persister] Can somebody help me parse what they mean by this? I ...

How do I create a table-per-class mapping with fluent nhibernate?

I'm trying to create a mapping similar to the following with fluent nhibernate: <class name="IAccountManager" abstract="true" table="IAccountManager"> <id name="Id"> <generator class="hilo"/> </id> <union-subclass table="DefaultAccountManager" name="DefaultAccountManager"> ...

where clause as a parameter

IN converting over a legacy application we need to convert named query to nhibernate. The problem is that the where clause is being set. here is the mapping <resultset name="PersonSet"> <return alias="person" class="Person"> <return-property column="id" name="Id" /> <return-property column="ssn" name="Ssn" /> <return-property co...

NHibernate: Meaning of interceptors return value

Hello, I think this is an easy question, but my googling is weak on this. I had the problem described in the following link with regard to a generated ID and cascading: https://www.hibernate.org/hib_docs/nhibernate/html/example-parentchild.html (towards the bottom) I fixed it using their suggested method of an Interceptor. Everythin...

NHibernate - joining on a subquery using ICriteria

I have a SQL query that I need to represent using NHibernate's ICriteria API. SELECT u.Id as Id, u.Login as Login, u.FirstName as FirstName, u.LastName as LastName, gm.UserGroupId_FK as UserGroupId, inner.Data1, inner.Data2, inner.Data3 FROM dbo.User u inner join dbo.GroupMember gm on u.Id = ...

NHibernate CompositeUserType: How to specify Sql Types?

Using NH 2.0, I have a custom type. It is composed of four properties, so I implemented ICompositeUserType. I want to specify length and precision for the string and decimal properties within the user type, to avoid specifying it with every usage in the mapping files. But there is only a PropertyTypes property to implement, which retu...

Optimize NHibernate Query

Hi In my system I do a centralized calculation on an aggregate with a lot of collections. I need ALL of the collections to be loaded before the calculation, and therefore I use a multicriteria that joins the collections on the root. The criteria i listed here below. It takes approx 500ms to run on my local setup, and that is a lot of ...

NHibernate: Finding out if a property is mapped to a field

Is there any way to find out if a property is mapped to a field. I would like this to generate something like a "generic like search": string[] words. words = search.Split(' '); Type type = typeof(T); Disjunction disjunction = new Disjunction(); foreach (System.Reflection.PropertyInfo property in type.GetProperties(...

Does NHibernate Criteria API support projections on collection properties?

I need to replicate the following working HQL query using criteria API. session.CreateQuery( "select c " + "from Parent p " + "inner join p.Children c " + "where p.Id = 9 " + "and c.Id = 33") .SetMaxResults(3) .List(); The query selects all the children that satisfy a certain criteria that belong to parents...

Audit logging nhibernate

could you provide some samples for audit loggin using NHibernate (ASP.Net+C# codd, not java code) ...

Learn SubSonic before NHibernate or Vice Versa?

We've been using our own DAL for our projects in our company and for the passed 2 projects this has causing us problems. Because of this I want to study SubSonic and/or NHibernate. Is it better to study SubSonic first or NHibernate? What are the advantages/disadvantages? From what I have read from related questions here NHibernate is mor...

NHibernate and a denormalised table

Working on a website that has Employee and Branch entities, using a database table "Employees" which also contains the branch id and branch name. I can't change the client's database so I need to map Employees and Branches from the same table. I guess I need some type of distinct clause in the mapping XML to get a distinct list or set o...

Querying NHibernate for paging in a web app.

Hi, Given a query for example: from Users u where u.Country = "US" I have a web app with a custom grid. How do I query NHibernate to bring back a specfic page results given page size and index??? Malcolm ...

DDD: Primary keys (Ids) and ORMs (for example, NHibernate)

Why is it considered OK to have an Id field in the domain entities? I have seen several solutions that provide base class with Id and Id-based GetHashCode/Equals. My understanding of domain model is that it should contain only things related to the domain. While in rare cases (trackable orders) Ids are meaningful, most of the time they ...