2
голосов
2ответов
258 просмотров

Merging entity changes in Nhibernate

Given I have a scenario where two users are editing different address object at the same time.* User 1 edits address.streetname only and saves and User 2 edits address.town and saves. Is there anyway I can configure nhibernate so that only the changed fields are updated and thus the changes are...

5
голосов
3ответов
4381 просмотров

How do you check if a table exists with NHibernate(or Fluent)?

Whats the best, most consistent way to check if a table exists in NHibernate (or with Fluent-NHibernate)? Is it even possible? I mean it seems like a simple task for such a heavy-duty ORM. Also on a related question, can you check if a set of tables or a whole schema exists with NHibernate?

4
голосов
1ответов
1252 просмотров

NHibernate CreateSQLQuery Transaction Issue

I have a simple method that does... Session.CreateSQLQuery(syntax).List<T>(); The issue is that when I execute this against a stored procedure that enlists a linked server connection I get the following error... The operation could not be performed because OLE DB provider "MSDASQL" for ...

4
голосов
2ответов
1945 просмотров

how to debug a NHibernate mapping?

I use NHibernate (2.0.1GA) with my project. At runtime I get the Invalid Cast (check your mapping for property type mismatches); [...] So it only says its unable to cast something. Thats a bit unprecise imho. My mapping file is pretty big (master table with about 50 colums plus 11 subsets)....

2
голосов
1ответов
563 просмотров

Using NHibernate Collection Filters with DDD collections

I am trying to map a domain model in NHibernate. The domain model is implemented with what I think is DDD style. The mapping works mostly but then when I try to use a collection filter on an a collection I get an exception which says: The collection was unreferenced. I know the problem comes fro...

1
голосов
2ответов
881 просмотров

NHibernate: Change from lazy=true to fetch=join brings back the world

I have a User object/mapping in my application. Each user has a list of contact information (phone, email etc) the mapping for the user contains: <bag name="ContactInfo" table="contact_info" lazy="true" cascade="all"> <key column="contact_id"/> <one-to-many class="...Cont...

2
голосов
1ответов
703 просмотров

NHibernate: HasMany components and Where/Contains clause

I'm trying to work out how to create a query using Linq to NHibernate. I have two classes like this: public class Foo { private ISet<Bar> _bars = new HashedSet<Bar>(); public virtual ISet<Bar> Bars { get { return _bars; } set { _bars = value; } ...

0
голосов
1ответов
144 просмотров

NHibernate: Or-clause with Components

I have two classes: public class Person{ public virtual string Name { get; set;} public virtual Address Address { get; set; } } public class Address{ public virtual string Street { get; set; } } Now I want NHibernate to give me all Persons where Name is equal to "Xyz" or Address.Street...

3
голосов
1ответов
743 просмотров

Calling a store procedure with nHibernate

How do you call a stored procedure with nHibernate? Specifically there are two cases where I am using store procedures: to return a scalar value and to return a set of results mapped to entities.

0
голосов
1ответов
55 просмотров

Why use IDictionary for Child Classes for NHibernate?

As I read here http://www.theserverside.net/tt/articles/showarticle.tss?id=NHibernate for example public class Department { private int id; private string name; private IDictionary classes; private IDictionary professors; } Why not use Generic List ?

4
голосов
4ответов
4840 просмотров

Mapping interface or abstract class component

Please consider the following simple use case: public class Foo { public virtual int Id { get; protected set; } public virtual IBar Bar { get; set; } } public interface IBar { string Text { get; set; } } public class Bar : IBar { public virtual string Text { get; set...

18
голосов
3ответов
5736 просмотров

Rehydrating fluent nhibernate configured DateTime as Kind Utc rather than Unspecified

Is there a way in fluent nhibernate to map a DateTime to rehydrate my entity with DateTime.Kind set to Utc rather than unspecified? I'm currently persisting a DateTime that is Utc, but the Kind coming back is always Unspecified, throwing off my time.

2
голосов
2ответов
929 просмотров

nhibernate many-to-many bag not inserting in the association table

I know this has been asked and answered a number of times, but I have two classes that are many-to-many. I've reciprocal mapped them using bags. Here is the NHibernate Mapping: Calendar: <?xml version="1.0" encoding="utf-8"?> <!--Generated by NHibernate.Mapping.Attributes on 2009-10-0...

1
голосов
1ответов
697 просмотров

nhibernate cross table query optimization

I have a query I've written with NHibernate's Criteria functionality and I want to optimize it. The query joins 4 tables. The query works, but the generated SQL is returning all the columns for the 4 tables as opposed to just the information I want to return. I'm using SetResultTransformer on ...

15
голосов
3ответов
4604 просмотров

Fluent NHibernate Column Mapping with Reserved Word

I've read that using a back tick ` should allow for using of reserved words. I'm using SQL Server and Fluent NHibernate and have a column name "File". If I map it with "`File" it tries using [Fil] so it's adding the brackets correctly, but dropping the "e" from the end. If I map it as "...

0
голосов
1ответов
1281 просмотров

NHibernate one to many with discriminator

I'm having an issue mapping what I would think is a fairly simple association. Here's an example of the domain model I'm trying to map: public class MyClass { IDictionary<string, DateTime> Dates { get; set; } } public class MyOtherClass { IDictionary<string, DateTime> Date...

1
голосов
3ответов
3573 просмотров

fetch=join to tables to one class NHibernate

I have read some post about fetch=join - http://nhforge.org/blogs/nhibernate/archive/2009/04/09/nhibernate-mapping-lt-many-to-one-gt.aspx (ser4ik.livejournal.com/2505.html) So I have some question, Forexample I have class <class name="AttributesInf" table="attr_inf"> <id name="Id...

1
голосов
1ответов
244 просмотров

Linq Expression in nHibernate

I have an interface, called IRepository. One of the methods in this interface is: IEnumerable<T> FindByQuery(Expression<Func<T, bool>> predicate); I then have (for example) an IUserRepository, that implements IRepository. In my implementation of IUserRepository, currently ca...

0
голосов
2ответов
1137 просмотров

NHibernate base and derived class mapping

Situation: I have a class MyClass and its "lightweight" version MyClassLite, so i have public class MyClass : MyClassLite I also use hbm file for mapping my classes (they are mapped to the same table). The thing is that when i try to get a list of MyClassLite entities, i get not only MyClassLi...

4
голосов
1ответов
3074 просмотров

key-many-to-one and key-property association: nhibernate won't DELETE items from set

I'll try to keep this terse, but hopefully won't miss any important information in my troubles. The code I believe provides all details, but I've left out the noise (it's VB, so there's lots of noise :) ). A "Case" object has many "Assignments": Public Class Case Property CaseId As Guid P...

1
голосов
2ответов
396 просмотров

Hibernate implementation of simple many-to-many relationships - Dictionary or List?

I have 3 DB Tables: Person, Address, and PersonAddress. Person Address is a simple join table (only stores the IDs of Person and Address). In my domain model, I have Person and Address. Person is configured to have a many-to-many relationship to Address (through PersonAddress). In code, this is ...

1
голосов
1ответов
977 просмотров

How to prevent NHibernate from creating duplicate records for referenced objects

I'm having trouble with saving an object into my database using NHibernate. My code looks like this: Image image = new Image { Url = 'test.jpg' }; Product product1 = new Product { Name = 'MyProduct', Image = image }; Product product2 = new Product { Name = 'MyProduct2', Image = image }; MySess...

4
голосов
3ответов
221 просмотров

Can someone help me understand why an auto-identity (int) is bad when using NHibernate?

I've been seeing a lot of commentary (from an NHibernate perspective) about using Guid as opposed to an int (and presumably auto-id in the database), with the conclusion that using auto-identity breaks the UoW pattern. This post has a short description of the issue, but it doesn't really tell me...

3
голосов
1ответов
2445 просмотров

NHibernate and DTOs

I am considering bringing NHibernate into a project but have a question on how read only DTOs would be implemented. Entities are easy, but what about scenarios where you have a field our two from multiple entities/tables that need to be mashed together for display data on a view. Surely it would ...

1
голосов
1ответов
820 просмотров

Fluent NHibernate : Mapping a Class with subclass problem

<id name="ID" column="CodigoPessoa" type="Int32" unsaved-value="0"> <generator class="identity"/> </id> <property column="CodigoCEP" name="CodigoCEP" type="String" /> <joined-subclass name="Core.clsPessoaJuridica,Core" table="tblPessoaJuridica" lazy="true"> ...

0
голосов
1ответов
188 просмотров

Nhibrnate POCO objects with relationships but no collections - Mutli tier

This is a bit of conceptual questions but I think it’s the right place to ask it. i am working with NHibernate for some time but I find it difficult to use the collections within the POCO objects 1. I think the proxy concept is nice but when you want o use it in multi tier architecture it become...

0
голосов
1ответов
614 просмотров

Hibernate mappings: Splitting up the file

Alright, I've got a quick question. I'm currently working with a legacy database, so I can't change around much. The database revolves around a single type, the entity. All other relevant data (except for customizable lists etc.) 'inherit' from this. I'm mapping this with a joined subclass appro...

2
голосов
1ответов
451 просмотров

How to Create a search function with nhibernate, linq?

I am going to build a search function today, c# asp.net. i need a push go get it rolling. i use nhibernate linq. it would be nice to do this with linq query. it need to be kinda dynamic, i am going to have several search criterias like gender, email, name, age and some more. this search query i...

0
голосов
2ответов
116 просмотров

Is nHibernate intended to replace database objects?

I've not yet found a clear answer to this and to clarify: With nHibernate and SQL server are you expected to disregard or migrate your business logic stored in your stored procedures, views and triggers into HQL or application code?

1
голосов
2ответов
2376 просмотров

NHIbernate DataReader Equivalent?

I'm somewhat new to NHibernate, so this question may be a no-brainer. Anyway, I'm replacing a project at work that uses ADO.NET that will now be using NHibernate(With LinqToNhibernate). This has worked fine so far, but I've run up against a function that needs to search through a large amount of...