nhibernate

NHibernate - Retrieve specific columns and count using criteria querie

This is my mapping file: class name="CRMStradCommon.Entities.OportunidadEntity,CRMStradCommon" table="oportunidad"> <id name="Id" column="id" type="int"> <generator class="native" /> </id> <property name="Titulo" column="titulo" type="string" not-null="true" /> <many-to-one name="Estado" column="estado" clas...

NHibernate cache/deletion problem?

I am using NHibernate and have a cache region specified in my NHibernate configuration: <cache region="HalfHour" expiration="1800" priority="3" /> I have an entity definition (UserDefinedGroup) which is set to use this cache region in read-write mode: <class name="UserDefinedGroup" table="Message_Groups"> <cache region="HalfHour"...

How do I unit test controllers for an asp.net mvc site that uses StructureMap and NHibernate?

I have an asp.net mvc2 application that is using StructureMap 2.6 and NHibernate 3.x. I would like to add unit tests to the application but am sort of at a loss for how to accomplish it. Say I have a basic controller called Posts that has an action called Index. The controller looks something like: public class PostsController : Cont...

SQLite with TransactionScope and Increment Identity Generator

When trying to use SQLite with System.Transactions TransactionScope with the identity generator as Increment, i noticed that i was getting an exception (given below along with code) when NHibernate was trying to retrieve the next Identity number. This seems to be because the new SQLite connection is doing a auto enlist of the current tr...

NHibernate: Mapping IList property

I have a table Order, Transaction, Payment. Class Order has the properties: public virtual Guid Id { get; set; } public virtual DateTime Created { get; set; } ... I added properties: public virtual IList<Transaction> Transactions { get; set; } public virtual IList<Payment> Payments { get; set; } These properties contain a record of...

Duplicate Items Using Join in NHibernate Map

I am trying to retrieve the individual detail rows without having to create an object for the parent. I have a map which joins a parent table with the detail to achieve this: Table("UdfTemplate"); Id(x => x.Id, "Template_Id"); Map(x => x.FieldCode, "Field_Code"); Map(x => x.ClientId, "Client_Id"); Join("UdfFields", join => { join....

NHibernate unmapped class exception

I am trying to implement a one-to-many relationship using NHibernate 2.1.2 but keep getting "Association references unmapped class" exceptions. I have verified that my hbm.xml files are embedded resource. Here are my classes and mappings. Any ideas? public class OrderStatus { public virtual decimal MainCommit { get; set; } publi...

fluent nhibernate named-query without using hbm file for the map

I am needing to create a named-query, and use it with one of the maps, that i currently have defined as a fluent map. is it possible to continue using the fluent map, and be able to create the named-query dynamically in code? or, is switching to a hbm map the only option? ...

Fleunt NHibernate not working outside of nunit test fixtures

Okay, here is my problem... I created a Data Layer using the RTM Fluent Nhibernate. My create session code looks like this: _session = Fluently.Configure(). Database(SQLiteConfiguration.Standard.UsingFile("Data.s3db")) .Mappings( m => { m.Fluen...

how to dynamically break NHibernation cascade

The NHibernate cascade setting in the entity mapping is static. Is there anyway to dynamically disable the "cascade" setting in code to avoid expensive cascade operation in NHiberate during a bulky data transaction? We do not want to use stored procedures or native SQL because we need to have the entity changes captured by NHibernate (au...

Which NHibernate.Mapping.Attributes should I use in my class to map a dictionary?

Hi Folks, I'm using NHibernate and I map my objects directly with attributes. I've seen similar questions but most of the case people use mapping files... or they give answers with links that don't exist anymore :) For the following class, which attributes do I have to add for the property Table which is a IDictionary? I guess it's som...

NHibernate mapping in Asp.Net using MySql

Hi, I'm new to NHibernate. Actually I'm trying to save the values ffrom two text boxes into MySql Database in asp.Net page. I that I got "Resource not found: WebApplication1.Sample.hbm.xml" error. But I can't fix this error. Can anyone help me to fix this one? ...

How did My Object Get into ASP.NET Page State?

I know what this error is, how to fix it, etc. My question is that I don't know why my current page I am developing is throwing this error when I am not using the foo class directly in any way, nor am I setting anything to the viewstate. I am using postbacks alot, but like I said, I am not storing anything in the viewstate etc one integ...

NHibernate WCF Rest IIS7 Fails with Security Exception

Here is the error: System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception. ---> System.Security.SecurityException: Request for ConfigurationPermission failed while attempting to access configuration section 'hibernate-configuration'. To allow all callers to access the data for ...

NotSupportedException on IQuery's Enumerable when using statelesssession

when trying to use the Enumerable method on a named query, with a Stateless session, as shown in the example at: http://www.nhforge.org/doc/nh/en/#batch-statelesssession i am seeing a NotSupportedException. the stack trace is as below: System.NotSupportedException: Specified method is not supported. at NHibernate.Impl.StatelessSession...

Nhibernate Auditing

I have a question about auditing. Most auditing examples use one audit table to track changes. However, we need one audit table per "regular" table. In other words, tblCustomer would also have tblCustomer_History. I can't figure out how to use a listener, and on update populate the history table as well. Any ideas? I'd hate to fall back ...

How to create mapping for a List<SomeNativeType> in FluentNhibernate ?

Hi all, I am trying to create a mapping file for the following Model using Fluent NHibernate. But, I am not sure of how to do the mapping for the List<string> in the mapping file. public class MyClass { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual List<stri...

NHibernate is not connecting to sql server.

When i set up a regular connection, it works, however when i try to use nhibernate, hibernate.cfg.xml, i m getting the following error. Message="A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and...

Object reference not set to an instance of an object Error

I'm trying to save text fields in MySql using NHibernate in Asp.Net frame work. But while executing this I got the error"Object reference not set to an instance of an object". If anyone knew help me... Here is the code. if (!Page.IsPostBack) { IList siteList; ISessionFactory factory = new NHibernate.Cfg.Configuration().Configur...

How can I inject multiple repositories in a NServicebus message handler?

I use the following: public interface IRepository<T> { void Add(T entity); } public class Repository<T> { private readonly ISession session; public Repository(ISession session) { this.session = session; } public void Add(T entity) { session.Save(entity); } } public class SomeHandler : IHandleMessages<SomeMe...