nhibernate

Fluent Nhibernate - Collection name naming convention

Is it possible to set a naming convention for all collection of an entity even if I use the Access Strategy or not, so that all collection names are {EnityName}s instead of {entityName}s (because of Access.CamelCaseField(Prefix.Underscore) the first letter is lower)? Or is there a way where I can tell NHibernate that it shall use the as...

Is there any considerations when using log4net in an application that uses NHibernate or Castle ActiveRecord?

Hi all, I used log4net in a sample application based on tutorial here. It works very well. But when I use same code and configuration in my main application, nothing works. My application is based on Castle ActiveRecord that itself is based on NHibernate. Both Castle ActiveRecord and NHibernate uses log4net internally. I'm suspicious ab...

nHibernate returning tinyint as 10 instead of 1

With C# 4 I am using CreateSQLQuery to do a simple select statement on a table with a tinyint. This is mapped to a byte on the C# side. When I run it, instead of 10 it will return 1 though, and if I use SQLYog with the same statement it works fine(returning 10 like it should). Thanks. EDIT: I have now tried with HQL aswell with the same...

The membership provider name specified is invalid. Parameter name: providerName

.Net4.0 MVC 2 NHibernate NUnit I'm trying to test user creation. From my test, I'm calling the following: MembershipCreateStatus status; // _session is my current NHibernate session. var mmp = new MyMembershipProvider(_session); mmp.CreateUser(username, password, "[email protected]", "", "", true, Guid.NewGuid(), out status); ...

Problem Understanding Fluent nHibernate Automapping and Relationship

I am a bit new to Fluent nHibernate and ran into a scenario with my schema I'm not sure how to address. Say I have two tables: Track TrackId UserId Name Users UserId Name Now, what I want to do is have the ability to access the related User object by track. For example: var track = repo.GetById(1); var userName = track.User.Name...

How do I write this condition into an NHibernate HBM mapping?

So I'm on an NHibernate crash course, and kinda hit a snag with the example below. Suppose I have the following .NET class: class A { int id; int type_var; List<B> someCollection; } class B { int id; string someText; } I'll probably map it like : <class name="A" table="A"> <id name="id" type="Int32"> ...

What is a good way to setup CRUD methods and SessionFactory in Nhibernate?

I currently have a NHibernateHelper class which creates a session factory. I keep recieving errors saying 'Session Closed!'. Am I going about this in the wrong way? The error occurs when I call the Add(Login login) which gets called after Add(User user) public class NHibernateHelper { private static ISessionFactory _sessionFactory; ...

Linq to Nhibernate using ANY

I have a requirement to query parent records if child records is one of given choice and i am unable to get this correctly the following works i.e if i get all the records and apply where clause on the results var linqSesssion = Session.Linq<PurchaseRequisition>(); linqSesssion.QueryOptions.RegisterCustomAction( c => c....

Caching not working for associated entities unless lazy loading specified in mapping file

I am having a problem getting associated entities to be cached unless they are specified (Not.LazyLoad() in mapping). If I build up a query in Criteria or Linq the Main Entity is cached, but not associated entities. IList<NewsItem> news; using (var session = factory.OpenSession()) { Console.WriteLine(...

Should an Entity ever know anything about its DAO?

I have a chance to introduce NHibernate to my group by using it with some new components that are being added to a legacy application. I'm trying to get my head around using the DAO pattern with NHibernate, and am stumped with an architectural question. In my fictional example, let's say I have CarDAO and a Car entity: public interfac...

NHibernate Audit Interceptor - current and previous values match when auditing a collection

Hi, I'm auditing certain values using a NHibernate Audit Inteceptor - I have inherited from the EmptyInteceptor and overridden the OnFlushDirty public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types) { For the most part the currentState and ...

Setting fetchmode in NHibernate is not eliminating SELECT N+1 issue

Hello, I'm struggling with something fairly basic. I have a one-to-many relationship and I'm setting the fetchmode to inner join in my Criteria query. I see the resulting SQL includes the join, but it also lazily fetches the child entities. What am I doing wrong? Mappings (Industry has many Manufacturers): public class IndustryMap :...

NHibernate/SQL Server multiple foreign keys to same table... Possible?

Hi, I have a SalesOrder table and a separate Address table. The SalesOrder has two addresses - thus avoiding use of a list, there are the Delivery and Invoice address. This is how they have been mapped in the SalesOrder mapping file: <many-to-one name="DeliveryAddress" class="Address" column="`DeliveryAddressGUID`" /> <many-to-one na...

Registering fluent nhibernate mappings for all assemblies in an application

Starting with some code: sessionFactory = Fluently.Configure(cfg) .Mappings(m => { List<Assembly> allAssemblies = new List<Assembly>(); string path = Assembly.GetExecutingAssembly().Location; foreach (string dll in Directory.GetFiles(path, "*.dl...

Complex querying with NHibernate

Hi, I have this problem: When I try to implement Ayende's complex searching found at: http://ayende.com/Blog/archive/2006/12/07/ComplexSearchingQueryingWithNHibernate.aspx with the object graph: Person: M:1 Address: M:1 Street: M:1 Place: ...

Many-To-Many relation through non-primary key for legacy system

I have a legacy system I'm working on and there is a particular relationship I'm having trouble with. The issue is that I need to relate Patient to HL7EPICareMeds... the relationship above isn't working, of course. From the table perspective, here is what I have Patient: PatientId : int, PK ClinicPatientId : varchar --- not unique ...

NHibernate mapping with an intermediate table

I am new to NHibernate and am running into some issues with mapping. Lets say I have a table: People PersonID PersonName PersonAge Then I have another table ParentRelaitions RelationID Parent (This is a PersonID) Child (This is also a PersonID) What I really want to get out of this is an object like this public class Person { s...

NHibernate: Retrieve SQL to be executed as a string

From an ICriteria, is it possible to retrieve a string containing the SQL that NHibernate is planning on executing? I know that is possible to receive a trace, but I was wondering if there is a method that can be called that generates the SQL (for example, so you don't have to actually flush to the database). ...

log4net: deny other components except than a specific one from logging

Assume you are using some libraries like NHibernate or Castle ActiveRecord that use log4net internally. Your application uses log4net too. It's possible to configure all applications to save logs into file or any other output. But the problem is by enabling log4net for my own application, other programs save their log into the log file a...

Nhibernate Interceptor is never called

I used NHibernate 2.1.2 and FluentNhibernate 1.1, database SQLITE In Memory (For unit testing purposes). Purposes of interceptor is to make proxy object returned by create criteria. I think i already register the interceptor to configuration correctly. but create criteria only return the naked object not proxied at all. I tried to put a ...