nhibernate

Can nHibernate map to a related table based on a column value?

create table Table1(attributeName varchar(100), attributevalue varchar(100), attributeLookupMethod varchar(50)) create table Table2(attributeName varchar(100), CSVAllowableValues varchar(1000) Based on the above 2 tables, using nHibernate, is it possible to only retrieve details from Table2 when Table1.attributeLookupMethod = 'Lookup'?...

NHibernate, DTOs and NonUniqueObjectException

Hi, We're using the DTO pattern to marshal our domain objects from the service layer into our repository, and then down to the database via NHibernate. I've run into an issue whereby I pull a DTO out of the repository (e.g. CustomerDTO) and then convert it into the domain object (Customer) in my service layer. I then try and save a new...

NHibernate Information

Hello All, I am new to NHibernate.Can anyone explain me How it deals with Large set of data? If I have 100gb of data ,i want to retrieve through Nhibernate,i think it is possible with ISession. If I use ISession,will it store in memory?If it stores in memory,if anychanges are done to database what will happen? Those doubts can lead me...

Using NHibernate.Mapping.Attributes on assembly with dependancies

Within my Entity assembly I have a class: public class MyClass : IAuditObject { // Implementation here } However the interface IAuditObject is defined in a separate Audit assembly. How can I successfully generate mappings using: NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(MappingFile,EntityAssembly); where Ent...

Using NHibernate and not referencing its assembly in the client application

Hi, We have a multi-tiered application using CSLA Business Objects and NHibernate ORM. In our Business Objects, we hold our collection data members as ICollection<T>, and in our object mapping files we define them as <set>s. Since NHibernate uses its own concrete types to fetch these collections, we have a problem when these collection...

NHibernate won't delete orphaned object

Hi everyone, I have a few classes that look like this public class Token { public int Id { get; set; } public ITokenInstance Instance { get; set; } } public interface ITokenInstance { int Id { get; set; } Token Token { get; set...

nHibernate ManyToManyToMany with Fluent

I have a structure here I have a ManyToManyToMany relationship. This is my (truncated) fluent mappings. public AgencyMap() { Id(x => x.AgencyId, "AgencyId"); Map(x => x.AgencyCode, "AgencyCode"); HasManyToMany<Personnel>(x => x.Personnel) .WithTableName("AgencyPersonnel") .WithParentKeyColumn("AgencyId") ...

Sql 2008 Filestream with NHibernate

I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { ...

NHibernate: difference Interceptor and Listener

Looking at all the possibilites of creation / update columns in NHibernate I mostly (Stackoverflow question, Ayende Rahien) see solutions with Listeners. The programmer who was programming this in my company used an Interceptor to achieve the same thing. Is there any difference between those two solutions ? (Is on of them obsolete, is...

HQL: order all items by a specific item in its map

Hi, I am quite new to Hibernate and currently struggling a bit with HQL. I have the following mapping and would like to get all "Industry" entities ordered by the "translation" for a given "culture_id" Code: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Domain.Industr...

How to find out the key field for a nhibernate object

Say I have the following query ICriteria query = session.CreateCriteria(typeof(T)); How can I find out the key field of T so that I can add an expression like so query.Add(Expression.In(keyField, someListOfObjects.ToArray())); Any ideas? ...

NHibernate - drilling down from the aggregrate root

Given an aggregate root X, which has many Y, and Y which has many Z... How can I drill down through the associations and select only those X's whose Z's have a certain property value? IList Xs = Session.CreateCriteria(typeof(X)) .CreateAlias("Ys", "Y") .CreateAlias("Y.Zs", "Z") ...

NHibernate: Generate a business key

What is the best way to generate a unique number for a business key? In the example below, our customer wants a number (OrderNumber) they can use to refer to an Order. <class name="Order"> <id name="Id" ... /> <property name="OrderNumber" column="order_number" /> </class> ...

NHibernate Win Forms Session Management

Hey Everyone.. I have used NHibernate in web applications before. I must admit that I am still learning NHibernate and do not totally grasp the art of session management. So I would like to use NHibernate within a Win Forms application that I am writing. I hear that session management in a Forms application is a bit different. Sessions ...

Projecting aggregates together with Entity using NHibernate

I have a pretty standard Orders table and an associated OrderRows table, say: Orders [id] INTEGER [name] ... OrderRows [orderId] INTEGER [quantity] INTEGER [unitPrice] SMALLMONEY [description] VARCHAR(...) For some situations I would like to retrieve a list of Orders together with a summary of totals, most of the time I don't care fo...

Implementing IPagedList<T> on my models using NHibernate

I have found when using NHibernate and creating a one to many relationship on an object that when the many grows very large it can slow down dramatically. Now I do have methods in my repository for collecting a paged IList of that type, however I would prefer to have these methods on the model as well because that is often where other de...

Would nhibernate be used in large scale projects like say facebook? (for arguments sake)

Hi, For those who know the inner workings of nhibernate, do you think a large scale web application like say facebook/myspace would use nhibernate? Or is nhibernate well suited for more low traffic sites like company sites etc? i.e. not enterprise ready because of its chatty nature? ...

Mapping NHibernate Many-to-Many

Hey all, I am trying to map a legacy database here and I'm running into a problem. In my schema I have a concept of Modules and a concept of Variables. Each Module consists of one or more Variables and each of these Variables has properties specific to that Module. A Varable sits on a Relation. Based on the classes below what is the b...

FirstOrDefault() breaks FetchType=join with Linq to NHibernate

If i do Session.Linq<MyClass>().Where(x => x.Id = someId).FirstOrDefault(); where MyClass has a set of eager loaded child object on it, the FirstOrDefault() seems to prevent this from working by adding a TOP 1 to the SQL. Is this just a bug (feature?) in Linq2NH (which i understand is being rewritten) or am I missing something? Is...

NHibernate delete operation

What are possible reasons why NHibernate does not perform delete operation? public bool Delete(MyType model) { using (var session = _sessionFactory.OpenSession()) session.Delete(model); return true; } I tried to call session.Clear() method, that didn't help either. I'm kind a confused. :/ MyType in this case has...