nhibernate

Nhibernate Map mapping with Composite Index

Hi guys, I'm new to NHibernate and am experiencing issues trying to model an IDictionary. The key of my dicionary is a complex type called 'Identifier' and the corresponding 'value' is of type string e.g. IDictionary<Identifier,string>. (apologies if the entity name 'Identifier' makes this confusing, its a domain term and I went with ...

Fluent NHibernate Many to one mapping

I am creating a NHibenate application with one to many relationship. Like City and State data. City table CREATE TABLE [dbo].[State]( [StateId] [varchar](2) NOT NULL primary key, [StateName] [varchar](20) NULL) CREATE TABLE [dbo].[City]( [Id] [int] primary key IDENTITY(1,1) NOT NULL , [State_id] [varchar](2) NULL ref...

Where is the NHibernate 3.0 source repository?

I've been looking everywhere. Maybe I'm just really nearsighted but I can't seem to find it anywhere. Link anyone? ...

NHibernate IUserType convert nullable DateTime to DB not-null value

I have legacy DB that store dates that means no-date as 9999-21-31, The column Till_Date is of type DateTime not-null="true". in the application i want to build persisted class that represent no-date as null, So i used nullable DateTime in C# //public DateTime? TillDate {get; set; } I created IUserType that knows to convert the entity ...

Querying nHibernate using ICriteria with GROUP BY and HAVING clauses

Hi everyone, I'm struggling to find a simple example of using ICriteria (or the new QueryOver API) in nHibernate to write a query like this: SELECT TOP (10) [t0].* FROM [dbo].[ContentView] AS [t0] INNER JOIN [dbo].[ContentTag] AS [t1] ON [t0].[UniqueID] = [t1].[ContentID] WHERE [t0].[TypeName]='Book' AND [t1].[Name] IN ('aspnet', 'sqls...

SQL Injection with Plain-Vanilla NHibernate

Hello, Plain-vanilla NHibernate setup, eg, no fluent NHibernate, no HQL, nothing except domain objects and NHibernate mapping files. I load objects via: _lightSabers = session.CreateCriteria(typeof(LightSaber)).List<LightSaber>(); I apply raw user input directly to one property on the "LightSaber" class: myLightSaber.NameTag = "Raw ...

How to configure multiple mappings using FluentHibernate?

First time rocking it with NHibernate/Fluent so apologies in advance if this is a naive question. I have a set of Models I want to map. When I create my session factory I'm trying to do all mappings at once. I am not using auto-mapping (though I may if what I am trying to do ends up being more painful than it ought to be). The problem ...

Fluent: Table name different from entity name

I am trying to use the automapping feature of Fluent with nHinbernate to map a class with a different name than the table itself is name. (This is purely for stylistic reasons we have a class named Foo which contains an object named Bar but the table name is FooBar. We would rather not have a property Foo.FooBar.) I can't find anythin...

Many-to-Many Relationship mapping does not trigger the EventListener OnPostInsert or OnPostDelete Events

I'm doing my auditing using the Events listeners that nHibernate provides. It works fine for all mappings apart from HasmanyToMany mapping. My Mappings are as such: Table("Order"); Id(x => x.Id, "OrderId"); Map(x => x.Name, "OrderName").Length(150).Not.Nullable(); Map(x => x.Description, "OrderDescriptio...

Manipulate score/rank on query results from NHibernate.Search

I've been working with NHibernate, NHibernate.Search and Lucene.Net to improve the search engine used on the website I develop. Basically, I use it to search contents of corporations specification documents. This is not to be confused with Lucene's notion of documents: in my case, a specification document (which I'll hereafter call a "...

Graduating from ASP.Net Webforms anti-patterns

On my current project, I'm stuck in an ASP.Net 2.0 Webforms anti-pattern quagmire. I am aware of the myriad of anti-patterns we're using (huge code-behinds, no separation of concerns, untestable code, and on and on). Now, I'm not interested in rescuing this application from this situation as it's too far gone. Instead, my focus is on ...

Using nhibernate <loader> element with HQL queries

Hi All I'm attempting to use an HQL query in a <loader> element to load an entity based on other entities. My class is as follows public class ParentOnly { public ParentOnly(){} public virtual int Id { get; set; } public virtual string ParentObjectName { get; set; } } and the mapping looks like this <class name="ParentO...

Setting Linq to NHibernate ADO Command Timeout

How do I increase the timeout in NHibernate Linq To Sql? Not the Connection Timeout but the ado command timeout. using (ISession session = NHibernateHelper.OpenSession(NHibernateHelper.Databases.CarrierCDR)) using (session.BeginTransaction(IsolationLevel.ReadUncommitted)) { lCdrs = (from verizon in session.Linq<Domain.Verizon>(...

How to fix a NHibernate lazy loading error "no session or session was closed"?

I'm developing a website with ASP.NET MVC, NHibernate and Fluent Hibernate and getting the error "no session or session was closed" when I try to access a child object. These are my domain classes: public class ImageGallery { public virtual int Id { get; set; } public virtual string Title { get; set; } public virtual IList<...

What is wrong with the following Fluent NHibernate Mapping ?

Hi, I have 3 tables (Many to Many relationship) Resource {ResourceId, Description} Role {RoleId, Description} Permission {ResourceId, RoleId} I am trying to map above tables in fluent-nHibernate. This is what I am trying to do. var aResource = session.Get<Resource>(1); // 2 Roles associated (Role 1 and 2) var aRole = session.Get<Ro...

SharpArch.Core.PreconditionException: For better clarity and reliability, Entities with an assigned Id must call Save or Update

When I do a save of an entity with assigned id I get a SharpArch.Core.PreconditionException: For better clarity and reliability, Entities with an assigned Id must call Save or Update My class is public class CompanyUserRepository : RepositoryWithTypedId<CompanyUser, string>, ICompanyUserRepository { public override Comp...

NHibernate 2.1.2 in medium trust.

I'm trying to configure nhibernate 2.1.2 to run in medium trust, without any luck. I have tried follwing the suggestions to run in medium trust and pre-generating the proxies. I then tried to remove all references to lazy loading setting the default-lazy="false" on all classes and bags. However this threw an exception asking me to confi...

sharp architecture question, nhibernate validation

I have marked certain properties in my domain object for the nhibernate validation 'framework'. If I do this in my controller explicitly: ICollection<IValidationResult> test = bla.ValidationResults(); I get the validation errors which I could add to my asp.net mvc modelstate ideally, i would like an exception being thrown during: ...

Fluent NHibernate IDictionary with composite element mapping

Hi there, i have these 2 classes: public class Category { IDictionary<string, CategoryResorce> _resources; } public class CategoryResource { public virtual string Name { get; set; } public virtual string Description { get; set; } } and this is xml mapping ...

Is this NHibernate sample still valid?

Or the concepts/best practices used there are now deprecated? I'm just starting to use NHibernate and I'm having a hard time finding good real life samples. http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx ...