nhibernate

NHibernate: Default value for a property over a null column

hi all! I'm working with an old database used by other applications, so i can't modify its structure. Sometimes i have nullable columns that i want to map as a non nullable type. For instance I have a nullable EndValidity column on database which i want to map on a non nullable DateTime, and, if null, it should be DateTime.MaxValue, or a...

Modeling varying perspectives of an aggregate in Domain Driven Design

In employing Domain Driven design I often encounter an issue regarding the various perspective on a domain object, especially when using NHibernate. Perspectives are essentially ways to view an domain object. For example, a simplified model: class Transaction { string Id { get; set; } string CustomerName { get; set; } DateTime Dat...

NHibernate calling Oracle stored procedure with schema prefix, how?

I have NHibernate calling stored procedure in Oracle working currently. However, how do I specify a schema prefix in the {call} syntax in the tag? I tried <sql-query name="my_sproc"> <return class="my_sproc_class" /> {call schema2.my_sproc (:p1)} </sql-query> But NHibernate run-time came back with 'schema2' not defined while 'sc...

log4net for NHibernate not writing anything into ASP.NET trace

Odd one this. I am using NHibernate with one website. I have configured log4net to show me all SQL and and errors in the trace. It all works swimmingly. I start using NHibernate in the other website - same solution, built on top of same class libraries. I copy the configuration data in web.config from one website to the other: <sectio...

Saving an NHibernate object after AutoMapping it to a DTO

We are trying to use NHibernate 1.1 to as the persistence layer behind a web service API. Nothing new there. We use Automapper to translate the domain objects we get from (Fluent-)NHibernate to DTO's which we send over the wire. The problem we are seeing is the following scenario: We read an object from the repository We translate...

Multiple return types from NHibernate.

Earlier I asked this question: http://stackoverflow.com/questions/3339477/loop-in-mysql-or-alternative/3339494#3339494 I got a great answer and it does work. Now in my application I am using NHibernate(in C# .NET 3.5) as the DAL. I dont really know how to deal with multiple return types, so I tried the following: var session = NHibe...

Selecting CompostiteUserTypes with Linq To nHibernate (v1)

Hi, We've a mature nHibernate project that has started using the linq provider in nHibernate contrib. As we are using nHibernate 2.0 we can't use the new provider under development in the trunk (against nHibernate 3.0). Whilst limited it's proved to be a perfect for our needs apart from one issue - whenever I select a CompositeUserType...

Why are some references missed when running my application?

I have the following project structure using a Domain Model, StructureMap and Fluent NHibernate: The problem I'm having is that Fluent NHibernate requires all of the following to be the bin directory of the website for it to work at runtime: Antlr3.Runtime.dll * Castle.Core.dll Castle.DynamicProxy2.dll FluentNHibernate.dl...

FluentNhibernate Mapping: Bidirectional one-to-many on same entity (Tree Mapping)

Hi, I want a bidirectional mapping in one class, in which the child can choose its parent (and save it to the database). How would I model that? This is what I have: public class MyNodeMap : ClassMap<MyNode> { public MyNodeMap () { Table("myTreeTable"); Id(x => x.Id).Column("NotParentId").GeneratedBy.Ident...

Is it still benefitial to think about NHibernate for .Net while there is LINQ to SQL possibility?

Hi, I am not very familiar with both LINQ to SQL and NHibernate. As far as I understand LINQ to SQL is a kind of replacement of NHIbernate for .Net in many ways. So does this mean that LINQ to SQL is a built-in replacament of NHibernate which let's a .Net developer to skip NHibernate and start to work with LINQ to SQL? Thanks ...

StaleStateException when changing id in nhibernate

Very new to NHibernate so I expect there will be a quick fix here. The code I'm looking at has an unorthodox design. public class Partner { public virtual int Id { get; set;} //note the set is not private public virtual String Name { get; set;} } and is mapped with FluentNhibernate's Automappings When Partner is created its ...

NHibernate second level caching with AppFabric

Has anyone used AppFabric for their second level caching? I know it's to follow the same api as for Velocity (nhibernate.caches.velocity) but wanted to know if anyone already had some production experience of using it and if they knew of any particular tips or problems? ...

Using DetachedCriteria to return generic list of non-AR type

I'm fiddling with my repository class and attempted to execute a query with a detached criteria. However, it doesn't seem to like me setting the result transformer to a non AR-type. public class IncidentRepository { public static IList<AuditReport> GetAllIncidentsToAudit() { DetachedCriteria dc = DetachedCriteria.For<Inc...

Selecting distinct objects from collection of objects using lambda expressions

We have a project using Fluent NHibernate. There is an object called BluePart with a property of Oem of type Oem. public class BluePart : DomainEntity { ... public virtual Oem Oem { get; set; } } The Oem object has several properties including OemCode and OemDescription. public class Oem : DomainEntity { ... public vi...

Need help with a 'No persister for:' exception with Fluent Nhibernate Automapping

Hello I'm having some problems with applying NHibernate Fluent Automapping. It worked great in a test project. But now.. Test method [PROJECTNAME].SubscriptionTest.SubscriptionConstructorTest threw exception: NHibernate.MappingException: No persister for: [PROJECTLIB].SubscriptionManagerRP The class (then again, the same exception a...

Hibernate optimistic locking..how it works??

Hi, I was reading the below blog about hibernate optimistic locking. I am planning to use it with hibernate. But, I have one concern. we have java code and c++ code, both connect to one database. While, java code can use hibernate to achieve optimistic locking, I want to make the c++ code do the same thing. Also, c++ code is using some ...

Hibernate, how to model this relationship

I have the below tables. create table logical_id_seq ( logical_id int auto_increment, primary key(logical_id) ); create table mytable ( physical_id int auto_increment, logical_id int not null references parent(logical_id), data varchar(20), primary key(physical_id) ); The second table uses first table auto-gen...

Where to reference session.BeginTransaction?

What is the dll that must be used? Where can I have it? I am using Nhibernate, can I use it with NHibernate? ...

How do I strongly type criteria when using NHibernate's CreateCriteria method?

I'm currently using NHibernate, for the first time, with Fluent NHibernate. I've gotten everything setup nicely, however now I've come to actual doing some data retrieval, it seems to have fallen short. I was expecting NHibernate, to allow me to do something like: session.CreateCriteria<TblDocket>() .Add(Restrictions.Eq(x=> x.Docke...

Nhibernate - How do I get ordered distinct results with QueryOver?

public class City { virtual public long Id { get; set; } virtual public string Name { get; set; } } City table contains duplicated Names and I want to remove duplicates. I also want the results to be ordered by Id. First I thought about the following query. select distinct Name from City order by Id; But this breaks with 'O...