nhibernate

NHibernate without log4net?

The problem is NHibernates dependany on log4net. I am trying to build an IoC app with interchangable Loggers, and this thing gets in the way. Is there a build out there without this dependancy or do I have to do some open source code hacking myself? ...

FluentNhibernate Intermediary Table

If we consider this example But now quantity is a Value Object instead of a primitive type: public class LineItem { public Quantity Quantity { get; set; } public Product Product { get; set; } } instead of: public class LineItem { public int Quantity { get; set; } public Product Product { get; set; } } how could i map...

Nhibernate: join tables and get single column from other table

Hi, I have the following tables: create table Users( Id uniqueidentifier primary key, InfoId uniqueidentifier not null unique, Password nvarchar(255) not null ) Create table UserInfo( Id uniqueidentifier primary key, Company nvarchar(255) not null, ContactPerson nvarchar(255) not null ) And InfoId is a foreign key referencing ...

Many to one mapping problem with NHibernate

Firstly I am relatively new to NHibernate. Got two tables on TaxMapping and Address. A single TaxMapping must have one address and one address can belong to more than one Tax Mapping. They are linked through foreign key TaxMapping hbm <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespa...

NHibernate: Where clause on one-to-many relationships doesn't work when column name is ambiguous

It is possible to specify an arbitrary SQL where clause for collection mappings. For example: <map name="myEntity" where="foo = 1" /> However if the column name is ambiguous for some reason, the sql fails. For example, this can occur if you are trying to use joins for example. Given that the table aliases are automatically generated...

One database, two applications, 2nd-level caching and NHibernate

What do I need to know when setting up caching using NHibernate, in the case that I have two applications running on different servers, but only one database. Are table dependencies generally sufficient to make sure that weird caching problems don't arise? If so, what sort of polltime should I look at? ...

Session.SetBatchSize does not change the batchsize

hi there, I create the Session factory like: FluentConfiguration cfg = Fluently.Configure().Database(MsSqlConfiguration.MsSql2005.ConnectionString( c => c.Is(dbConnectionString)).**AdoNetBatchSize(100)**.ShowSql()). Mappings(m => m.FluentMappings.AddFromAssembly(mappingAssembly)). ...

Receiving Index Out of Range with NHibernate

I'm hoping that someone can help me with this issue. I've been racking my brain and my project is due very soon. Thank You in advance. I'm receiving an index out of range exception when inserting a new record. After searching endlessly for information, it was suggested that the number of column values in my mapping do not match that in ...

No component for supporting the service after upgrading to NHibernate 2.1

Up until recently I had a working service using NHibernate 2.0. I have upgraded to 2.1, but now try to instantiate the ItemManager: IItemManager manager = Container.Instance.Resolve<IItemManager>(); I get an exception: Castle.MicroKernel.ComponentNotFoundException was unhandled by user code Message="No component for supporting the ...

NHibernate: How do I ignore the cache and go directly to the database?

Consider a typical NHibernate context class. public class SampleContext : NHibernateContext { public SampleContext(ISession session) : base(session) { } public IQueryable<Person> People { get { return Session.Linq<Person>(); } } public Person GetPerson(int id) { get { return Session....

Filtering NHibernate SubType with ICriterion

Is there any way I can filter my NHibernate query on the SubType field before I hit the database by adding an ICriterion to my executing DetachedCriteria? My code looks something like this: DetachedCriteria detachedCriteria = DetachedCriteria.For(typeof(MyObject)); ProjectionList projectionList = Projections.ProjectionList(); ...

NHibernate Hanging on Lazy Loaded Query

First of all, I'm using Fluent NHibernate with LinqToNHibernate. I've got a query to do a search on a table based on what data the user entered. So, for example, I'm doing something like this: 'build the initial query that we will filter--this is lazy loaded Dim results As IEnumerable(Of Customers) = Me.GetCustomers() ...

NHibernate explicit fluent column mapping

I have a set of fluent object mappings that looks like this: public class UserMap : ClassMap<User> { public UserMap() { Map(x => x.Id); Map(x => x.Status); } } public class SpecialUserMap : SubClassMap<SpecialUser> { public SpecialUserMap() { Map(x => x.Property); } } public class Direct...

NHibernate doesn't delete db record when object is set to null?

I have two classes: Family and Address. A family has a physical address and a mailing address. The mapping file for Family looks like: .... <id name="Id" column="Id" type="Int32" unsaved-value="0"> <generator class="native"></generator> </id> <many-to-one name="PhysicalAddress" class="Address" column="PhysicalAddressId" cascade="all"...

Is it possible to use Ninject with a static property?

I have a static SessionFactory class that initializes an NHibernate session factory. Because this process is expensive (~5 sec.), I want it to be static so it's only done once, at the beginning of runtime. The configuration can take a database parameter parameter like so: public static IPersistenceConfigurer DbConfig { get; set; } pub...

nhibernate hql subquery performance

I have written an hql to support paging string hql = @"select distinct mr from MediaResource as mr where mr.Deleted= false and mr.Type = :typeId"; SimpleQuery<MediaResource> q = new SimpleQuery<MediaResource>(hql); q.Se...

When does NHibernate cause Sql:BatchStarting/Sql:BatchCompleted

I notice that some queries created by NHibernate are executed as batches whereas others are not. When I profile my database using Sql Server Profiler, the event type for these queries is listed as 'SQL:BatchStarting' followed by 'SQL:BatchCompleted', rather than simply RPC:Completed. Is there any reason why some statements are run as ba...

Force an eager select in NHibernate

I am trying to eagerly fetch collections using selects, but all I am getting is inner joins. What is going on? Session.CreateCriteria(typeof(Foo)) .SetFetchMode("Bars", FetchMode.Select) .CreateAlias("Bars", "b") .SetFetchMode("b.Bazes", FetchMode.Select) .List(); I have tried changing FetchMode to Eager but that doesn...

Fluent NHibernate one-to-many insert/delete problem

I am trying to add and remove elements from a list mapped as .HasMany(), but nHibernate executes some weird queries on this simple scenario: if (Profile.Artists.Any(x => x.Artist == artist)) { Profile.Artists.Remove(Profile.Artists.Single(x => x.Artist == artist)); } else { Profile.Artists.Add(new Artist { Artist = artist, User =...

Clarification on NHibernate Event mechanism

i am in the middle of re factoring an application and i've applied an interface on most entities. I want to change the Save/Update behavior of these entities using the Event mechanism of NH2.1.1. As such i'm implementing an NHibernate.Event.ISaveOrUpdateEventListener public class SaveOrUpdate : ISaveOrUpdateEventListener { public v...