nhibernate

nHibernate safe delete

Is there any way to check if it is safe to delete record from table ? for example : daoStudent.Delete(id); doesn't throw exception if it has any child records , but I would like it to. I could take other actions like making student inactive. ...

NHibernate: How to map a column on a referenced table to a primitive in my object?

If I have the following existing table schema +-------------------+ +-------------------+ | Address | | Country | +-------------------+ +-------------------+ | Line1 | +--->| CountryId | | Line2 | | | Name | | City | | +-------...

How do I map nested generics in NHibernate

In NHibernate you can map generics like this <class name="Units.Parameter`1[System.Int32], Units" table="parameter_int" > </class> But how can I map a class like this? Set<T> where T is a Parameter<int> like this Set<Parameter<int>> My mapping hbm.xml looking like this fails <class name="Set`1[[Units.Parameter`1[System.Int32], Un...

Fluent NHibernate - How to use an enumerator to identify subclass?

Hi, Im trying to map the following classes: public abstract class ScheduleType { public virtual int Id { get; set; } public virtual TypeDiscriminatorEnum Discriminator { get; set; } } public class DerivedScheduleType : ScehduleType { public virtual bool MyProperty { get; set; } } public class ScheduleTypeMap : ClassMap...

nHibernate disables my log4net logs

So, we had a little ETL app that had some issues with updates. Which were nicely solved in an afternoon sprint with nHibernate. But this app relied upon log4net to push logging output to a few different destinations based upon command line switches. Once we got nHibernate wrapped into the app, it ETL'd flawlessly. But the logging functio...

NHibernate + ASP.Net MVC + User Activity Feed

I am looking for the most appropiate way of dealing with a user activity feed on my social networking site. At the moment i have several activities which can appear on the news feed such as: Users joins the site User comments on a post User adds a a post to their favourites User adds a new post to the site Here is a simplified versio...

Querying NHibernate

Hi All, We are using NHibernate as our ORM for the project and we have only database read only feature. The application will not be updating,deleting or inserting any records into the database it will be just querying the database for records. My question is which is the best method to query the database with NHibernate in the scenari...

NHibernate Query Execution Plan?

HI all, How does NHibernate executes the queries? Does it manipulates the queries and uses some query optimization techniques? And what is the query execution plan followed by NHibernate? ...

(Fluent)NHibernate: Mapping an IDictionary<MappedClass, MyEnum>

I've found a number of posts about this but none seem to help me directly. Also there seems to be confusion about solutions working or not working during different stages of FluentNHibernate's development. I have the following classes: public class MappedClass { ... } public enum MyEnum { One, Two } public class Foo { ...

Why are all public methods in an entity class declared as virtual when in use with NHibernate?

Why are the entity class methods declared as public virtual, when the class is to be mapped with a table using NHibernate. Is the answer that NHibernate will be able to override these methods at runtime? ...

Logging NHibernate SQL queries

Is there a way to access the full SQL query, including the values, inside my code? I am able to log SQL queries using log4net: <logger name="NHibernate.SQL" additivity="false"> <level value="ALL"/> <appender-ref ref="NHibernateSQLFileLog"/> </logger> However, I would like to find a way to log SQL queries from the code also. ...

Lock mechanism between process on multiple machines

I have a C# application with NHibernate that must do some operations over a SQL Server DB. Our goal is to run this app multiple times in the same machine and also in other machines. Actually app insert a row in a SQL Table and check if the first row with minimum date is the row with the correct PID and machine name so the app set the l...

Queries for Objects in NHIbernate?

I am going through the book NHIbernate in Action. I have read querying chapters in it which I understood also using ICriteria and IQuery. But I came across one more topic Queries for Objects....What does this statement mean actually? There was a query "from Bid" which retrieves all instances of a particular persistent class. Wasn't thi...

NHibernate automatically update my objects to database without calling SaveOrUpdate in Asp.Net MVC

I'm learning Nhibernate, and there are something I'm not quite sure. I hope you can help me to check my code. As you see the following code which I did not call "SAVE" and it still updates the value to the database. There might be a situation which I want to change the objects' value and do not want to save them back to the database. How...

NHibernate Projection using SqlQuery...

Hi, I'm trying to reproduce the HqlQuery style 'select new ObjectToProjectOut' functionality. i.e. take a list of columns returned from a query and return as a list of ObjectToProjectOut types that are instantiated using a Constructor with as many parameters as the columns in the query. This is in effect what 'select new ObjectToProjec...

Tools for NHibernate

Can anyone throw some light on tools that can be used with NHibernate and which perform the below mentioned tasks: Generates the Mapping File Generates the Entity Class Generates the Configuration file And also provide information whether these tools are open source or licensed. Thanks ...

NHibernate one-to-many different between SQLITE and Oracle

I have a one-to-many mapping that works in sql lite, but then blows up in Oracle. If I make a slight change, it will work in Oracle, but not in SQLITE. Here's my mappings: This works in SQL Lite <many-to-one class="NHibernate.Spike.Data.Entities.ClientRecord, NHibernate.Spike.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nul...

Better to serialize NHibernate DetachedCriteria or LINQ-to-NHibernate expressions over WCF?

What I'd like to do: 1. Create an arbitrary LINQ query based on user-selected criteria that will 2. Query against a proxy collection (facade) that 3. Converts the query to NHibernate DetachedCriteria and serializes OR just serializes the LINQ expression and then 4. Sends the serialized query to the server via WCF, where 5. The service im...

Active Record or NHibernate generating invalid Sql for paging on SqlQuery

When applying Paging (using SetFirstResult and SetMaxResults) to an ActiveRecord SqlQuery, with nHibernate 2.1.1 GA and ActiveRecord 2.0.1 the following sql is generated: SELECT TOP 40 FROM (, ROW_NUMBER() OVER(ORDER BY account.Name, account.State) as __hibernate_sort_row select account.Name <rest o...

MS Entity Framework VS NHibernate and its derived contribs (FluentNHibernate, Linq for NHibernate)

I just read this article about the Entity Framework 4 (actually version 2). Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate. NHibernate and its current contributions of FluentNHibernate and Linq f...