nhibernate

How to use Generic in LINQ to SQL Fetch Operation ?

I am using LINQ to SQL for my data retrieval. One common fetching scenario is to or fetch by some criteria. The code is below. public EmployeeRegistrationView FetchByEmailID(IDictionary<string, string> criteria) { var selEmployeeRegistrationView = from P in db.EmployeeRegistrationViews ...

ASP.NET MVC: run code after view has rendered (close db transaction)

Hi, I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls to the database via NHibernate should be inside a transaction, however code inside the view kicks off database calls in some instances. Thus there is a need to be able to commit the transaction after the view has rendered. For example displaying a list of us...

Morfik - suitability for medium-scale web enterprise applications

I'm investigating technologies with which to develop a medium-scale (up to 100 or 200 simultaneous users) database-driven web application, and someone suggested Morfik. However, outside of the Morfik company I can find practically zero community support - no active blogs, no tutorials, no videos, no books - and this is of some concern (e...

How can I transfer an NHibernate PersistentGenericSet over WCF

I'm trying to send objects retrieved by NHibernate over WCF, but whenever a have a property of ICollection I get an exception. When NHibernate gets the data from the database this property is intitialized with an instance of PersistentGenericSet. Is there a way I can send a PersistentGenericSet over WCF? -or- Is there some way makin...

DataTable identity column not set after DataAdapter.Update/Refresh on table with "instead of"-trigger (SqlServer 2005)

Within our unit tests we use plain ADO.NET (DataTable, DataAdapter) for preparing the database resp. checking the results, while the tested components themselves run under NHibernate 2.1. .NET version is 3.5, SqlServer version is 2005. The database tables have identity columns as primary keys. Some tables apply instead-of-insert/update ...

How to query collections in NHibernate

Hi, I have a class: public class User { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IDictionary<string, string> Attributes { get; set; } } and a mapping file: <class name="User" table="Users"> <id name="Id"> <generator class="hilo"/> </id> <property name=...

How do I tell if enteties changed in the current transaction with nhibernate?

I have a web service that uses nhibernate, calls to the web service go to a simple method that opens the session, begins a transaction and then calls code I don't control that sometimes modifies entities, after that code returns the transaction is commited. I need to add some extra processing inside the transaction that only happens if ...

NHibernate Configuration issue

Hi Friends, I got following error whenever anything in project is going to be updated. I am unable to understand what this error message trying to tell. can any body help me in to this. Server Error in '/' Application. Unexpected end of file has occurred. The following elements are not closed: hibernate-configuration. Line 1, position ...

NHibernate Collection Mapping - Read Only Properties

I have the following class public class Person { private IList<Person> _children; public IEnumerable<Person> Children { get; } public void AddChild(Person child) { // Some business logic and adding to the internal list } } What changes would I have to make for NHibenrate to be able to persist the Child co...

NHibernate exception "Session is closed! Object name: 'ISession'."

Hi, I am getting the folloinwg error from NHibernate: System.ObjectDisposedException: Session is closed! Object name: 'ISession'. at NHibernate.Impl.AbstractSessionImpl.ErrorIfClosed() at NHibernate.Impl.AbstractSessionImpl.CheckAndUpdateSessionStatus() at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) at NH...

nhibernate mapping: delete collection, insert new collection with old IDs

my issue lokks similar to this one: (link) but i have one-to-many association: <set name="Fields" cascade="all-delete-orphan" lazy="false" inverse="true"> <key column="[TEMPLATE_ID]"></key> <one-to-many class="MyNamespace.Field, MyLibrary"/> </set> (i also tried to use ) this mapping is for Template object. this one and the Field...

Fluent Nhibernate Mapping Problem

I'm fairly new to nhibernate and fluent nhibernate, I have an issue with associating a collection to a query. In the database I have a well and have 4 associated AFEs. The problem I'm having is that the collection of AFEs is not populating correctly. No matter what I do, I get 4 AFEs in the collection but they are all the same object....

Spring HibernateTemplate: how it deals with transactions?

Could you explain, what happens behind the scene? Transaction management when using this template in Spring is absolutely unclear. What if I invoke 10 DAO methods that all use the same Hibernatetemplate and I invoke them one after another? Every method runs within its own transaction? It's not effective is not it? ...

Tool to generate Fluent NHibernate mappings

I am trying to integrate NHibernate into an existing application with several hundred tables. Due to the fact that there apparently wasn't a strict adherence to conventions, I am unable to use Automap. As a result, I'm going to use Fluent to manually map over all of the associations. Rather than doing it by hand, I'm hoping that there i...

Nhibernat mapping aspnet_Users table

My User table I want to map to aspnet_Users: <class name="User" table="`User`"> <id name="ID" column="ID" type="Int32" unsaved-value="0"> <generator class="native" /> </id> <property name="UserId" column="UserId" type="Guid" not-null="true" /> <property name="FullName" column="FullName" type="String" not-null="t...

Inspecting Lucene.NET index with Luke want to replicate NHibernate.Search view

Hi, I am trying to put together an index using terms, which I specify as a comma separated list. I want to replicate the display in Luke as seen here: http://ayende.com/Blog/archive/2009/05/03/nhibernate-search-again.aspx But my index value just shows as a single field with the comma separate list value. For example: Tags term,ano...

Fluent NHibernate caching with automapping

I'm trying to understand how to configure Fluent NHibernate to enable 2nd-level caching for queries, entities, etc... And at the same time use automapping. There is very little information online on how to do that. Sure it can be done when mapping the classes one by one... But how about automapping? Here is my configuration code so far:...

IIS 7.5 fails to open database after computer machine on that database server is working restarts.

Hi. There is a problem that bother me for some time. I have an asp.net mvc that uses NHibernate for modeling the database. The infrastructure is the following: Windows 2008 R2 for all virtual machines. IIS 7.5 is working on one virtual machine. Sql Server 2008 is working on another virtual machine. We have couple of databases, two that s...

LEFT OUTER JOIN in NHibernate with SQL semantics

Hi, Is it possible to use HQL/ICritera to produce a query with the same semantics as the following SQL query: select table1.A, table2.B, count(*) from table1 left join (select table2.parent_id, table2.B from table2 where table2.C = 'Some value') as table2 on table2.parent_id = table1.id group by table1.A, table2.B order by table1.A ...

How to order records by a computed column in Criteria API?

How can I write the below HQL query using the Criteria API? select s.Name, sum(q.PointsObtained), sum(q.TotalPoints) from Student s join s.Quizzes q group by s.Name order by (sum(q.PointsObtained) / sum(q.TotalPoints)) desc ...