nhibernate

Fluent Nhiberhate And Missing Milliseconds

I am using Fluent Nhibernate and Nhibernate for my current project. I need to record the time to the millisecond. I have this for my mapping Map(x => x.SystemDateTime) .CustomType("Timestamp") .Not.Nullable(); I genertaed the hbm.xml files and the line is the following: <property name="SystemDate...

Entity Framework vs. nHibernate for Performance, Learning Curve overall features

I know this has been asked several times and I have read all the posts as well but they all are very old. And considering there have been advancements in versions and releases, I am hoping there might be fresh views. We are building a new application on ASP.NET MVC and need to finalize on an ORM tool. We have never used ORM before and h...

NHibernate change tracking does not pick up changes to a custom type (IUserType)

I have a model with a Dictionary<string, string> property that is stored in the database using JSON. I am using a custom NHibernate type to map the dictionary to and from a JSON-encoded string, which works fine. My problem is that when I flush the session, and the only property that has changed is this dictionary, then the entity is not...

Fluent NHibernate/SQL Server 2008 insert query problem

Hi all, I'm new to Fluent NHibernate and I'm running into a problem. I have a mapping defined as follows: public PersonMapping() { Id(p => p.Id).GeneratedBy.HiLo("1000"); Map(p => p.FirstName).Not.Nullable().Length(50); Map(p => p.MiddleInitial).Nullable().Length(1); Map(p => p.LastName).Not.Null...

converting to Fluent NHibernate sessionmanager

Hello, I am changing my application to use Fluent NHibernate. I have created my Fluent mapping files and have now moved onto configuring my Session Manager. Currently, I use the following code - private ISessionFactory GetSessionFactory() { return (new Configuration()).Configure().BuildSessionFactory(); } Along with my hiberna...

NHibernateUnitOfWork + ASP.Net MVC

Hi Guys, hows it going? I'm in my first time with DDD, so I'm begginer! So, let's take it's very simple :D I developed an application using asp.net mvc 2 , ddd and nhibernate. I have a domain model in a class library, my repositories in another class library, and an asp.net mvc 2 application. My Repository base class, I have a construct...

NHibernate: How to test a many-to-one relationship is lazy?

I've got a simple many-to-one relationship (an Order has a Customer who placed it). Here's the except from my Order mapping: <many-to-one name="Customer" column="FK_CUSTOMERS" class="MyApp.Customer, MyApp" not-null="true" lazy="proxy" cascade="none" /> Yet the following does not pass: configuration.GetClassMapping(typeof(Order)) ...

nHibernate: Query tree nodes where self or ancestor matches condition

I have see a lot of competing theories about hierarchical queries in fluent-nHibernate or even basic nHibernate and how they're a difficult beast. Does anyone have any knowledge of good resources on the subject. I find myself needing to do queries similar to: (using a file system analog) select folderObjects from folders where folder....

Not loading associations without proxies in NHibernate

I don't like the idea of proxy and lazy loading. I don't need that. I want pure POCO. And I want to control loading associations explicitly when I need. Here is entity public class Post { public long Id { get; set; } public long OwnerId { get; set; } public string Content { get; set; } public User Owner { get; set; } } and mappi...

Nhibernate - How to get rid of unwanted text cast

Hello, I am using Nhibernate 2 and PostgreSql The above code generate a query with a cast on expression res = _session.CreateCriteria(typeof(C)) .Add(Restrictions.Eq("Exp", Exp)) .AddOrder(new Order("Fr", false)) .SetMaxResults(MW) .List<C>(); Exp is a c...

ORM Against a Service-Wrapped Data Source

We are tasked with migrating an existing set of entities (currently POCOs persisted with NHibernate against an MSSQL database) to now persist to some kind of web service (yet to be built, either RESTful or SOAP-based, and that we control). I like how NHibernate encapsulates the persistence concerns and lets us maintain a logic-rich, per...

NHibernate ICompositeType Implementation for Uri

Is there any ICompositeType implementation for System.Uri? I want to be able to use this query: where a.Uri.schema == 'https'. ...

LockMode With Subclasses

I'm using Fluent Nhibernate with the following query on DerivedClass which extends BaseClass: var query = Session.CreateCriteria<DerivedClass>().SetLockMode(LockMode.Upgrade) What I want is the lock hints (updlock, rowlock) to be applied to both DerivedClass and BaseClass, but the generated SQL only applies the lock hints to DerivedCla...

How do I tell NHibernate to load a component as not null even when all its properties are null?

Hi, I have a Date class which wraps over the DateTime? class (aids in mocking DateTime.Now, our domain ,etc). The Date class class only has one protected property : DateTime? date public class Date { protected DateTime? date; } // mapping in hbm <component name="CompletedOn"> <property column="StartedOn" name="date" access="fie...

NHibernate query with Projections.Cast to DateTime

I'm experimenting with using a string for storing different kind of data types in a database. When I do queries I need to cast the strings to the right type in the query itself. I'm using .Net with NHibernate, and was glad to learn that there exists functionality for this. For the example I'm using this simple class: public class Foo...

Fluent NHibernate no data being returned

Hello, I have been successfully using NHibernate, but now I am trying to move to Fluent NHibernate. I have created all of my mapping files and set up my session manager to use a Fluent Configuration. I then run my application and it runs successfully, but no data is returned. There are no errors or any indication that there is a proble...

NHibernate: miss data on refresh

I have a problem with entity refreshing in NHibernate. I have an entity with IList property; this property is mapped with "list" tag on hbm mapping file. Now, on maintenance window if I remove some elements from the list (without saving) and then I call NHibernate refresh to restore changes the list items, that previously I removed, ar...

Nhibernate join on a table twice

Consider the following Class structure... public class ListViewControl { public int SystemId {get; set;} public List<ControlAction> Actions {get; set;} public List<ControlAction> ListViewActions {get; set;} } public class ControlAction { public string blahBlah {get; set;} } I want to load class ListViewControl eagerly...

NHibernate, VS 2010

Здравствуйте, ANRY! Совсем недавно при прохождении практики от университета, столкнулся с NHibernate. Тут же прочитал вашу статью "Hello NHibernate!". Понадобилось реализовать некое подобие магазина: то есть, есть товар, клиент, заказ. Соответственно создал 4 таблицы в MSSQL 2010: Товар(id_товара, название, цена), Клиент(id_клиента, имя...

Service Layer are repeating my Repositories

Hi all, I'm developing an application using asp.net mvc, NHibernate and DDD. I have a service layer that are used by controllers of my application. Everything are using Unity to inject dependencies (ISessionFactory in repositories, repositories in services and services in controllers) and works fine. But, it's very common I need a met...