nhibernate

Where is the session located ? in client browser or at the server side ? and why it is used in hibernate ?

I know that the session is used for the database in Hibernate, but what is the task of the session in database? Does anyone know about this? ...

Why it is necessary to create only single instance of SessionFactory ?

my code is static { try { sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } here i created only single instance of SessionFactory the above code work c...

Temporal data using NHibernate

Hi, Can anyone supply some tips/pointers/links on how to implement a temporal state-table with NHibernate? I.e., each entity table has *start_date* and *end_date* columns that describe the time interval in which this this row is considered valid. When a user inserts a new entity, the *start_date* receives 'now' and the *end_date* will ...

NHibernate : Projection List

I have the following code: criteria.SetProjection(Projections.ProjectionList() .Add(Projections.Property("_personId")), "_ personId") .Add(Projections.Property("_firstName"), "_firstName") .Add(Projections.Property("_lastName"), "_lastName") .Add(Projections.Property("_address"), "_ address ") .SetResultTransformer(Trans...

Fluent NHibernate and Stored Procedures

I have a basic Customer/Order/OrderItem/Product object graph. Customer has Many Orders, Order has Many Order Items, Product has many Order Items. These are successfully mapped using FNH. I've hit a snag with configuring a stored procedure & fluent-nhibernate. There is not a native way to map stored procedures in fluent-hibernate FNH ...

Unable to cast object of type NHibernate.Collection.Generic.PersistentGenericBag to List

Hello there, I have a class called ReportRequest as: public class ReportRequest { Int32 templateId; List<Int32> entityIds; public virtual Int32? Id { get; set; } public virtual Int32 TemplateId { get { return templateId; } set { templateId = value; } } public virtua...

Entity Framework 4 vs NHibernate

A lot has been talked about Entity Framework first version on the web (also on stackoverflow) and it is clear that it was not a good choice when we already have better alternative like NHibernate. But I can't find a good comparison of Entity Framework 4 and NHibernate. We can say that today NHibernate is the leader among all .NET ORMs, b...

Fluent NHibernate table-per-class-hierarchy need to use .Where() ?

I have the following mapping for a set of contact classes based off an abstract Contact class implementation. public class ContactMapping : ClassMap<Contact> { public ContactMapping() { Id(x => x.Id).GeneratedBy.GuidComb(); Map(x => x.CreatedDate).Not.Nullable(); Map(x => x.Value).Not.Nulla...

Does NHibernate HQL support the UNION ALL keyword?

After extensive googling, I still can't find a definitive answer to this question. Some old articles/blog posts I've seen say not at all. Some say yes if the underling database supports it. Which is it? I asked on the nhusers group with no answer so far. Any help would be appreciated. ...

How to use NHibernate CurrentSessionContext within a Timer

I build a repository class that use ISessionFactory.GetCurrentSession() to find the current session that its methods should work with and used CurrentSessionContext.Bind to bind a session within my application. Inside the NHibernate config I used thread_static as my current_session_context_class. This worked perfectly so far. On each th...

NHibernate: is there a way to mark an object as NOT dirty?

I have a situation where I need to load part of an object graph using custom SQL (for performance reasons). So I load up this collection using my custom SQL (ISession.CreateSQLQuery()) and then I assign that list to a property on another entity object. The problem is that when I assign the list to the property, it makes that entity dir...

NHibernate creates proxy via session.Load(), but not via Linq or Criteria API

I have an odd problem in my current project. Lazy loading for queries does not work. When I query a list, nhibernate fetches all associations separately. I extracted small parts of it and put it into a separate solution. Basically what I've got now, is a Account-Table and a AccountSync-Table. Both have an ID and a URL, while the ID is j...

Need to provide nhibernate configuration a path to an assembly

I have a solution that uses NHibernate to generate the db schema based on the mapping files. I'm trying to break that functionality out of the solution so it can be used as a stand alone console app. I was able to provide a path to the mapping files like so: NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration(); ...

xVal & Nhibernate.Validation using external definitions

I am using NHibernate Validation with external definitions (that is not using attributes on classes, implementing validation by inheriting from ValidationDef<>) I am using the RulesProvider from here as I am using NHV 1.2 I am trying to get client side validation working in xVal. But because the validation does not come from the attrib...

How to save a single entity or entities within an NHibernate Session without saving other dirty entities?

How do I flush certain parts of a session but not other parts? For example: ISessionFactory sessionFactory = CreateSessionFactory(); ISession session = sessionFactory.OpenSession(); Employee first = session.Get<Employee>(FirstEmployeeId); Employee second = session.Get<Employee>(SecondEmployeeId); first.Name = "Michael Johnson"; second....

Adding a projection to an NHibernate criteria stops it from performing default entity selection

I'm writing an NHibernate criteria that selects data supporting paging. I'm using the COUNT(*) OVER() expression from SQL Server 2005(+) to get hold of the total number of available rows, as suggested by Ayende Rahien. I need that number to be able to calculate how many pages there are in total. The beauty of this solution is that I don'...

WCF Nhibernate Service with Integrated Security=True error

Hello there, I am working on a WCF Service(implemented with Fluent NH), and it is hosted as a Windows Service. I am using a console application to test calling service methods. Now, when I set connection string in hibernate.cfg.xml as <property name="connection.connection_string">Server=dev;Initial Catalog=DBTest;Integrated Security...

NHibernate - How do I change schemas during run time?

I'm using NHibernate to connect to an ERP database on our DB2 server. We have a test schema and a production schema. Both schemas have the same table structure underneath. For testing, I would like to use the same mapping classes but point NHibernate to the test environment when needed and then back when in production. Please keep in min...

Nhibernate N+1 query problem

I need help with NHibernate. I'm using 2.1, but have tried this on 3 as well, with same results. Any help most appreciated! When doing an ICriteria query using NHibernate, it executes both the query, and then for each result in the query, it executes another query to select an associated object, which is already returned in the initial ...

fluent nHibernate and relation to Asp.net Membership tables

I'm using fluent nHibernate (automapper) and at the same time use Asp.net Membership, but how do i reference aspnet_Users table? maybe create a new user table with only the ProviderUserKey as field? and always make references to that table? and use Membership.GetUser(..) to get name etc. ...