nhibernate

How would you handle this situation with nHibernate

I have 2 tables in my database: Category BlogEntry Each BlogEntry has 1 or more Categorys associated with it. If I want to get a BlogEntry by its ID, I also want to get its Category information. Maybe this example doesn't illustrate exactly a scenario where this would make sense, but say I want to load the Category ID and Name only...

Learning NHibernate

I am interested in learning NHibernate. So, I found this: http://www.summerofnhibernate.com/ I would like to watch these, but I am afraid that the videos are for a previous version of NHibernate. Is this true and if so should I still watch them? Is there a current video series? Any other suggestions for learning NHibernate? ...

Why is NHibernate AdoTransaction's finalizer called?

I'm profiling out unit & integration tests, and I find the a lot of the time is spent on the finalizer of NHibernate.Transaction.AdoTransaction - this means it is not getting disposed properly. I am not using AdoTransaction directly in the code, so it's probably used by some other object inside NHibernate. Any idea what I'm forgetting t...

Unable to enlist in a distributed transaction with NHibernate

I'm seeing a problem in a unit test where Oracle is thrown an exception with the message "Unable to enlist in a distributed transaction". We're using ODP.net and NHibernate. The issue comes up after making a certain number of commits to the database inside nested transactions. Annoyingly, this is failing on the continuous integration ser...

Parent-child tree hierarchy with NHibernate

I have a Group. That group can contain groups and this needs to be mapped with NHibernate. I have done this before but this time I got an existing database that does not really store the data like I would like it too. The database looks like this: Groups Id Groups_Link ParentId ChildId I have no clue about how to map this? Edit: ...

What are some good examples of web 2.0 sites that use nHibernate?

Are there any live, web 2.0 type applications that use nHibernate? Looking for some real world usage on a high traffic web site/service. ...

How would I map this in nHibernate?

Trying to wrap my head around nHibernate, curiuos how this scenerio would be handled: Post (postID, title, content, dateCreated) Category (categoryID, name, postCount) post_to_categories (postID, categoryID) If I create a Post, it should insert into Post, insert into post_to_categories and update the postCount in Category. I am plan...

Can I pass in T.Property? Also, ideas for improving this method?

Or possibly there is a better way. I am building a dynamic query builder for NHibernate, we don't want to put HQL directly into the application, we want it as ORM agnostic as possible. It looks like this currently: public override IEnumerable<T> SelectQuery(Dictionary<string, string> dictionary) { string t = Convert.ToSt...

How do I test the NHibernate FetchMode.Eager properly?

Is there any way to write an integration test to test that the FetchMode.Eager works correctly? I want to verify that it's not going to the database when I retrieve MySubObject. The code: public MyObject GetEager(string name) { return Session .CreateCriteria(typeof(MyObject)) .SetFetchMode("MySubObject", FetchMode....

find out the property name within IUserType.NullSafeGet

Is it possible to find out the property name of the current column within the IUserType.NullSafeGet function? The string[] names parameter of the IUserType.NullSafeGet function does only provide the aliases of the field that was used for the query. But in order to get a list of attributes that are attached to the owners (object owner of...

NHibernate, ActiveRecord, Transaction database locks and when Commits are flushed

This is a common question, but the explanations found so far and observed behaviour are some way apart. We have want the following nHbernate strategy in our MVC website: A SessionScope for the request (to track changes) A ActiveRecord.TransacitonScope to wrap our inserts only (to enable rollback/commit of batch) Selects to be outside ...

NHibernate - how to enforce uniquenes??

My scenario is as follows: I have some objects (Messages) that can be tagged So I have a Tag entity and many-to-many relationship The above is done and working Now, when tagging, I'd like to save new tags only if they don't exist (where existence is checked by tag title) if the tag already exists, I'd like it to be recognized and attac...

ProxyFactoryFactoryNotConfiguredException, while lazy is false

I'm using NHibernate and getting an ProxyFactoryFactoryNotConfiguredException while calling _factory.BuildSessionFactory();. I have lazyness disabled by default and have no property that is mapped as lazy. Is the proxy factory needed anyway? ...

Select multiple entities in Criteria Query

In NHibernate HQL you can select multiple entities for a given query like this example. var query = session.CreateQuery("select c,k from Cat as c join c.Kittens as k"); Obviously the real world situation has more complexity but that is the basics. Is there a way to do this in a Criteria query? ...

Getting started with NHibernate

Hi everybody! I am trying to develop my Hello World program in NHibernate. My codes are as follows: MyClass.cs ---------- using System.Collections.Generic; using System.Text; using System; using NHibernate.Collection; using NHibernate.Mapping; using Iesi.Collections; namespace NHibernate__MyClass { public class MyClass { ...

How can I mimick nhibernate's repository pattern with linq2sql?

I was reading this blog entry: http://blogs.hibernatingrhinos.com/nhibernate/archive/0001/01/01/the-repository-pattern.aspx I like how they made a interface that has all the basic CRUD queries for you, and you can use it accross all your entities/tables. Can this also be done with linqtosql as well? Code: public class Reposit...

NHibernate Identity fields

http://stackoverflow.com/questions/1020128/getting-started-with-nhibernate How can I generate identity fields in nHibernate using Hilo algorithm? ...

NHibernate: double update of dirty entity if adonet.batch_size > 0?

I have an entity that when it has a property updated, it ends up causing two updates with exactly the same SQL. There are many possible causes of this, but I've verified that there's a problem only if adonet.batch_size is anything greater than 0. If adonet.batch_size = 0, then there's just one update. Has anybody else ever run into this...

Caching data loaded with NHibernate

In my application I want to cache data loaded with NHibernate. I don't want to use the second level cache of NHibernate as this cache is not really meant to cache an entire graph of objects. But what is the best strategy to make sure I don' have any lazy loading proxies and/or collections in my graph? ...

How do you map an entity -> interface relationship using Fluent NHibernate?

given the following class definition: public class Order { public IProduct Product {get;set;} } I have this (fluent) mapping References(x=>x.Product, "ProductId"); And get this exception: An association from the table Orders refers to an unmapped class, which makes sense because it doesn't know what implementation I will pass to ...