nhibernate

NHibernate HiLo ID Generator. Generating an ID before saving

Hi All, I'm trying to use 'adonet.batch_size' property in NHibernate. Now, I'm creating entities across multiple sessions at a large rate (hence batch inserting). So what I'm doing is creating a buffer where I keep these entities and them flush them out all at once periodically. However I need the ID's as soon as I create the entitie...

What does NHibernateUtil.Initialize do ?

I have inherited a piece of code which calls NHibernateUtil.Initialize. I am relatively new to NHibernate and have not been able to work out specifically what calling NHibernateUtil.Initialize does. What does it do and in what scenarios should it be called ? ...

Not Calling NHibernate Session Close

I'm looking at some code that I know has a memory leak and I think I know why. however; I am curious about the bloody details. At the beginning of a request there is a call to session.OpenSession(); in order to get an ISession but at the end of the request there is no call session.Close(); and/or session.Dispose(); What objects are sta...

Fluent NHibernate - Many To One Relation

There is a table of Products and Categories. Many products have one category. So, in Product mapping, how can I write the correct code to map with its category? In Product class: Is it something like: References(x => x.Category).Column........ ...

Transactionscope

Where can I reference TransactionScope? What is it used for? Where can I have information related to that? Can it be used to solve nested transactions? ...

Automatic join with NHibernate / Many-to-one / HQL

Hello everyone, I'm working on a .NET C# project on which I had to use NHibernate Mapping Attributes to map my objects to my tables in my database. Now let's explain what my problem is. I have two mapped classes, for example ClassA and ClassB. In my database, table A contains a foreign key referencing the primary key of table B. Hence...

NHIbernate OR Criteria Query

I have the following mapped classes Trade { ID, AccountFrom, AccountTo } Account {ID, Company} Company {ID} Now I cannot figure out a way select all trades where AccountFrom.Company.ID = X OR AccountTo.Company.ID = X I can get AND to work using the following: criteria.CreateCriteria("AccountFrom").CreateCriteria("Company").Add(Res...

Performance Issues with ActiveRecord / NHibernate and SQL CE

Hello, Our team is currently working on a WPF Desktop application with ActiveRecord and SQLCE 3.5 for backend. We've been experiencing some strange performance issues when executing queries or creating/updating records. In some cases opening a form which has a few grids and data elements that need to be populated, can take around 2 seco...

Looking to design a tool to Translate Business logic from Stored Procedures to C# Business Layer

Without getting into a discussion about whether the business logic should be in the database or at the application layer, since it has been covered elsewhere. My team is translating 100K+ lines of PL/SQL code and moving the logic from the database into the application. We were using VB6 with straight calls to Oracle 9i Stored Procedure...

Why does Linq to Nhibernate produce an outer join

I have an issue with Linq to Nhibernate producing queries with outer joins. For example: return Session.Linq<ClientContact>().Where(c => c.Client.Id = 13).ToList(); Produces a query similar to: SELECT... FROM mw_crafru.clientcontact this_, mw_crafru.client client1_, mw_crafru.relationshiptype relationsh4_ WHERE t...

NHibernate 1.2 in a .NET 4.0 solution

Hello, I have some projects based on NHibernate 1.2 and I'd like to add them to a .NET 4.0 solution, but I get an AmbiguousMatchException. No matter if these projects are targeted to 2.0 or 4.0 framework. It works if I add them to a .NET 3.5 solution. Does anyone have experience with that? Here is the exception: [AmbiguousMatchExcep...

Creating database views with NHibernate

Does any one know how to create a view from hibernate with the results of a criteria query? We've got some legacy parts of our application that use views generated by the app for data retrieval and I like to tie the new NHibernate stuff into those for minimal friction. I'd turn it into an extension method so I could eventually do stuff...

Is there a resource which describes all of the log4net loggers used by NHibernate?

I would like to heavily customize my NHibernate logging for performance diagnosis reasons. Is there a resource of all of the available loggers? Even better would be a resource describing what each logger logs at the various log levels. ...

NHibernate Child Session not flushing properly

We have implemented an auditing system via NHibernate event listeners. In our listener, we track all changes and write them out to our audit tables. To try and maximize performance, we have used Guid's for our audit tables so that we can batch our updates as much as possible. We are writing out updates to a "child session" which we g...

NHibernate criteria API - how do I add a clause to compare one date to another date minus a value

I'm trying to build a criteria object using NHibernate that will compare date1 to date2 minus a value. In Sql Server I'd do this: select * from table where date1 < DateAdd(Day, 2, date2) Can anyone tell how I would do this in NHibernate? Cheers EDIT I should have specified this earlier, I'd like to find out how do do this using the ...

Can NHibernate detect when another program has written new data to a shared SQLite database?

I have two C# programs that share a single SQLite database file. One program (let's call it Writer) writes new data to the database. The other program (Reader) reads it. Both programs use Fluent NHibernate and System.Data.SQLite to access the DB. Currently, I've just got a big Refresh button on my Reader program, and the user has t...

Should I always use transactions in nhibernate (even for simple reads and writes)?

I know that for multi part writes, I should be using transactions in nhibernate. However what about for simple read and writes (1 part) ... I've read that it's good practice to always use transactions. Is this required? Should I do the following for a simple read ?? or can I just drop the transcaction part all togather ? public P...

Error with Nhibernate: System.Data.SqlClient.SqlException: Incorrect syntax near 'Index'

Hey all, i have an nhibernate solution and i'm trying to do a save, but i'm getting this error: Test method HelloMusic.Core.Test.CrudTests.TestTrackAdd threw exception: NHibernate.Exceptions.GenericADOException: could not insert collection: [HelloMusic.BLL.Track.Credits#20][SQL: INSERT INTO Tracks_Credits (TrackID, Index, CreditID) VA...

What is the best option, transaction locking for distributed systems?

I am using NHibernate and really new to that. My dilemna is when I open a web browser, it shows the table data. Meantime another person opens another web browser and hence read the existing data from the database. Meantime, I make changes in the my pages and save. And the user save his changes afterwards. When I reload the page, I...

NHibernate bag - real collection items instead of proxies

Hi all, I am experiencing some strange problems with NHibernate and the usage of proxy items within a bag. My mapping looks something similar to: <?xml version="1.0" encoding="utf-8" ?> <bag name="Markets" table="ITPUserWatchlistMarkets" cascade="none" lazy="false"> <key column="UserWatchlistId" /> <many-to-many class="Swan.Dom...