nhibernate

How can I use Expression<T> in NHibernate?

I have read the very good blog post of Rob Conery Crazy Talk: Reducing ORM Friction How can I generalize this interface so I can implement it with NHibernate? using System; using System.Collections; using System.Linq; using System.Linq.Expressions; public interface IRepository<T> { IQueryable<T> GetAll(); Pag...

having trouble converting a query to hql

Hi I'm pretty new to HQL (well, nhibernate in general) and am currently building a simple app to learn more about it. I've run into problems trying to express the following sql as hql though, and would be very grateful for any ideas. Here's the query: select * from parent p where p.id in (select p.parentid from child c where c.create...

Can I turn off NHibernate ShowSQL after initial configuration (at runtime)

My NHibernate configuration is set to show sql for all interactions. Because of this, some of my larger integration tests are performing poorly (particularly when generating the test report). Is there a way to turn off ShowSql at runtime - and then switch it back on programmatically. ...

Is Configuration.GenerateSchemaUpdateScript() in NHibernate a good way to manage db schema changes

I'm using NHibernate mappings as a defining schema for my app in the development phase and for the schema definition I'm using the NHibernate.Tool.hbm2ddl.SchemaExport() method to generate a createscript. Now, I have considered using the Configuration.GenerateSchemaUpdateScript() method to generate database changescripts like this: va...

Free NHibernate helper tools?

Are there any free tools to help simplify working with an NHibernate project in .NET 3.5? Primarily, I'm looking for some kind of code and config file generator to automate some of the more tedious parts of working with NHibernate. ...

NHibernate - Populate a single property from a stored procedure.

Currently have the following mapping file: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernateHelpers" assembly="App_Code.NHibernateHelpers"> <class name="NHibernateHelpers.Fixture, App_Code" table="Fixture_Lists"> <id name="Id" column="UniqRefNo"> <gen...

How can I preload records with parent-child self-references using Castle ActiveRecord?

My SQL table looks like this: CREATE TABLE Page ( Id int primary key, ParentId int, -- refers to Page.Id Title varchar(255), Content ntext ) and maps to the following class in my ActiveRecord model: [ActiveRecord] public class Page { [PrimaryKey] public int Id { get; set; } [BelongsTo("Parent")] publ...

NHibernate: accessing configuration properties (Sql dialect) at runtime

Hello, I would like to retrieve at runtime the values for the "dialect" and "connection.driver_class" properties specified in the configuration file. Do you know how to do that? Many thanks, Nicola ...

NHibernate: One base class, several mappings

I'm relatively new to NHibernate, but have been using it for the last few programs and I'm in love. I've come to a situation where I need to aggregate data from 4-5 databases into a single database. Specifically it is serial number data. Each database will have its own mapping file, but ultimately the entities all share the same basic...

What's the Hi/Lo algorithm?

What's the Hi/Lo algorithm? I've found this in the NHibernate documentation (it's one method to generate unique keys, section 5.1.4.2), but I haven't found any good explanation of how does it work. I know that Nhibernate handles it, and I don't need to know the inside, but I'm just curious. ...

Using NHibernate with output parameters

Does anyone know if NHibernate supports returning output parameters from stored procedures? I've had a search in the documentation but can't really find anything that confirms either way. ...

NHibernate performance insert

Hi, I'm doing some tests with nhibernate and I'm modifying batch_size to get bulk inserts. I'm using mssql2005 and using the northwind db. I created 1000 object and insert them to the database. I've changed the values of batch_size from 5 to 100 but found no change in the performance. I'm getting value of around 300ms. Using the sql pr...

JSON.NET and nHibernate Lazy Loading of Collections

Hi there Is anybody using JSON.NET with nHibernate? I notice that I'm getting errors when i try to load a class with child collections. Thanks Graham ...

NHibernate many-to-one and unique constraint violation

Hi all, I have a problem trying to model a many-to-one relationship in NHibernate, where the object on the 'one' side has a unique constraint on a column. The problem is as follows: I have two tables, 'Person' and 'Country'. Each Person has one and only one Country associated with it. A Country can have many Persons (really! :)) and a ...

DB-side encryption via NHibernate

Hi people, We're looking to encrypt a field using DB-side encryption via NHibernate (most examples we've come across are app-side, which is not what we would like). The issue has been raised a couple of times, but no answers yet it seems. On SQL Server 2005, for instance, and forgetting key-related issues for now, this means INSERTin...

NHibernate 2.0.1 Criteria: IsNull restriction throwing exception

I've been utilizing NHibernate 2.0.1.4000 on all current .NET 3.5 SP1 projects and have had no problems with any other queries (utilizing either the Query or Criteria APIs), until some new business logic dictated the necessity of a new query in this particular project against the application's database that needs to retrieve records with...

Hibernate: Avoiding reading all the records to memory at once

I have a large amount of rows in the database from which I need to create an XML document. I am using hibernate 3. The basic list() method in Criteria and Query interfaces looks dangerous: I quess it pretty much has to read all the records into memory even if I only iterate over them. Or is there some lazy loading magic? If not, I seem t...

NHibernate, Codesmith and project physical architecture

Recently I tried CodeSmith templates for NHibernate. As many of you might watched, there is a video explaining how to create a Petshop.Data using these templates. My question is what is the correct architecture in this approach? Should we have a BLL (or Services) layer to interact with this Petshop.Data or directly call ManagerFactory in...

NHibernate IInterceptor implementation(without extending domain classes with special properties)

How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties? for example: in my case i would like to get object and just moment before update/insert db add to that object some additional information (like user id or computer name) by using IInterc...

Import Process maxing SQL memory

Hey guys, I have an importer process which is running as a windows service (debug mode as an application) and it processes various xml documents and csv's and imports into an SQL database. All has been well until I have have had to process a large amount of data (120k rows) from another table (as I do the xml documents). I am now findi...