nhibernate

NHibernate intersection

Hi, How can i do intersection in nhibernate? is select enterprise.Id from Enterprises intersect select enterpiseID from vEnterprise ...

Are all NHibernate References LazyLoaded by default?

I have a (fictional) class with Fluent-mapping: public class Customer { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Employee Responsible { get; set; } public virtual IList<Order> Orders { get; set; } } public class CustomerMapping : ClassMap<Customer { public Cus...

NHibernate Cache Provider Differences

Hi All, I've been using NHibernate for a while now, I'm still wondering what the differences are between the the Second Level Cache Providers ? Do some perform better\worse ? What is popular and why ? For claraty I'm talking about NHibernate.Caches.MemCache NHibernate.Caches.Prevalence NHibernate.Caches.SharedCache NHibernate.Cache...

Nhibernate : generates insert then update statements, in multithreaded environment leads to deadlock issues

I've experienced the following scenario when using NHibernate with SQL Server 2005. I have a business process which involves the following steps: Start transaction Create nhibernate mapped object Save nhibernate mapped object Perform other business workflow steps Update nhibernate mapped object in step 2 Commit transaction In a sing...

Mapping a Collection of Enums in NHibernate

I'm trying to map a collection of enums in NHibernate using Fluent NHibernate, and then perform queries against the contents of that enum collection, but the system throws exceptions every time. I have a Widget class, mapped to the Widget table. There is also a WidgetType enum, and a single instance of Widget can have many WidgetTypes, ...

Multiple row update in nhibenrate

Hi guys, So I was wondering whether it is best to update multiple rows in a database using an hql query or calling nhibernates save after modifying each object.. I know that the answer is the HQL query but please give me adequate reasons for the same. but there are disadvantages of using an HQL query right like my API has a hard depend...

Why one-to-many does not work as expected in NHibernate?

I have very simple situation and really don't have a clue why this isn't working. This is my schema: **[item]** id (PK) symbol **[item_version]** id (PK) item_id (FK->ITEM) symbol These are my mappings: item.hbm.xml <class name="Core.Model.Entities.Item, Core.Model" table="item" lazy="false"> <id name="Id" column="id" type="lo...

Castle 2.5/NHibernate/Magnum/NServiceBus

Hi, Is there anyone out there having a working Castle 2.5 based stack including NHibernate (2.1.2.x), FluentNHibernate, Magnum, NServiceBus, rRhino.Security up and running built for .Net 4? thanks in advance & greetings, chris ...

Finding the row with matching relations using HQL

I am using Castle ActiveRecord and NHibernate. I have an Instance class which has a many-to-many relationship with a Component class. I would like to find the instance which is related to a specific set of components. Is this possible in HQL (or anything else in NHibernate)? The linq version of this function would be: public Instanc...

Inconsistent results between NHibernate Query and intended results

Hello all, I have the following query in HQL : public IEnumerable<Player> PlayersNotInTeam(Team team) { return Session.CreateQuery("from Player p where p.Sex = :teamSex and p.Visible and p.Id not in (select pit.Player from PlayerInTeam as pit join pit.Roster as roster join roster.Team as team where team = :teamId)") .SetPar...

Do we have to have to enable MSDTC to use TransactionScope?

Do we have to have to enable MSDTC to use TransactionScope? I am using TransactionScope and I had error message telling me that the MSDTC not enabled. So I have enabled it. Why am I having this error message? Is that normal? What`s MSDTC use? Is transactionScope SQLSecver specific? ...

Can I use inline views with the criteria API?

Does NHibernate support inline views using criterias? Google doesn't seem to return any relevant results. Here is the query I need to convert preferably using criterias. SELECT COUNT (incident_count) AS incident_count, SUM (total_customers) AS total_customers, MAX (longest_etr) AS longest_etr, COUNT (DISTINCT crew_c...

Fluent nHibernate Eager Load one class

Hi, How do I Eager load a collection of objects in Fluent nHibernate? I going to loop through the collection and at the moment I'm getting an individual database call on each loop. I'm using the auto mapper have this override public void Override(AutoMapping<ParticipantCompany> mapping) { mapping.Not.LazyLoad(); } bu...

sql server 2005 problem - defrag necessary?

Hi, I insert some data into a sql server 2005 database using NHibernate. Before I insert an object I check whether it already exists based on its primary key. Every 100000 or so lookups this seems to throw some exception (if I do the same via sql it takes ages as well). A defragmentation of the hard disk seems to help but seems a bit st...

Use Spring.NET with NHibernate 3

Hi, I am trying to use the sping.net nhibernate integration with the latest nhibernate 3 release. Unfortunately spring.net references nhibernate 2.1.2.4000. I tried to fix it with an assembly redirect to 3.0.0.1002 but this yields the error: The method "IsInstrumented" in Type "Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory" of A...

How to build a generic repository

I'm developing a web application in ASP.NET MVC with NHibernate. Based in articles and tutorials I've found at Google, I'm using Repository for my classes. I have 10 classes and 10 repositories. Today I figured out that 90% of mine repositories are exactly equal each other, except for the class. This is one example: public class Promo...

NHibernate log4net performance problem - how to disable?

I was profiling our ASP .NET application to try and reduce the CPU usage and fond some strange behaviour regarding NHibernate and log4net. Over 50% of the time on our app is spent in the log4net GetLogger and CreateRepository methods, which are called from ExecuteReader in NHibernate. The screenshot below is a jetBrains dottrace hotspot...

ASP.NET NHibernate transaction duration

Currently in our ASP.NET app we have 1 session per Request, and create one transaction every time we load or update and object. See below: public static T FindById<T>(object id) { ISession session = NHibernateHelper.GetCurrentSession(); ITransaction tx = session.BeginTransaction(); try { ...

How can I perform sorting ORDER BY expression in NHibernate

select p.Id, sum(inc.Quantity) from Products p join Incomes inc group by p.Id order by sum(inc.Quantity) >0 This query gives NHibernate.Hql.Ast.ANTLR.QuerySyntaxException on ORDER BY clause. I wonder is it possible to overcome this error and perform sorting by some expression? UPDATE I need to sort products list by name, price etc...

How can I use "nu install ..." to install nhibernate 3 alpha?

Hi all, I've started using nu and I'm really starting to like the way it managed packages for .net libraries. On this page: http://nu.wikispot.org/Current_Packages it says that you can install the nhibernate alpha version with nu, however I can't for the life of me figure out how. Can anyone help me with the command I would need? Tha...