nhibernate

Fluent NHibernate List<string> Length

I have a List that I am trying to get into the DB and am coming up with the following assert: {"ORA-12899: value too large for column \"GDATA\".\"CNVTOOLBOX\".\"TOOL\" (actual: 387, maximum: 255)\n"} I am overriding the automapping with the following: public class CnvRootMap : IAutoMappingOverride<CnvRoot> { public void Override(...

Fluent NHibernate mixed mapping properties

Hi! I'm trying to use fluent nhibernate to auto map most properties of a class, and then manually map 1 or 2 properties of that same class (without having to manually map all the other variables in the class map). I have a class with a couple of dozen properties, but one of those properties is a string which needs to be a long length. ...

nhibernate fetching entire tree

Hi, I need help fetching tree hierarchy from db using nhibernate 3.0 QueryOver.Of<Enterprise>(() => entAlias) .JoinAlias(() => entAlias.ChildEntities, () => childEntityAllias, JoinType.LeftOuterJoin) .TransformUsing(new DistinctRootEntityResultTransformer()) I am getting only the two level of the graph (parent and its child...

What is the use case for Access.BackingField in Fluent NHibernate?

The documentation for Access.BackingField() indicates that this: Sets the access-strategy to use the backing-field of an auto-property. I understand that auto-properties get compiled with backing fields, but if the property is by definition a vanilla getter/setter, what advantage is garnered by going to the backing field directly v...

Filters not being applied for many-to-one reference

I have a bit of an odd scenario where I have a table that references a view that contains rows which are user-specific. The view has a unique row ID, but it is never used to reference the item. Instead a unique value is derived from a combination of a client ID, user ID, and an object key. public BarMap() { Table(Datab...

nHibernate trying to update instead of insert a new object

I am using nHibernate attributes which generates this... <class name="xxx.Message.MtMessage, xxx" lazy="false" table="tblCore_MtMessage"> <id name="MtMessageId"> <generator class="identity" /> </id> <property name="MtMessageStatus" /> <property name="ApplicationMessageId" /> <property name="IsPremium" /> ...

Troubleshooting object hydration

Is there any way to logging to turn up for troubleshooting why an object wouldn't have been hydrated? Making the exact same call at two different points is yielding different results in terms of object hydration: Call 1 – Able to hydrate a bar object when opening an foo NHibernate.Engine.QueryParameters - BindParameters(Named:NHiberna...

Distinct elements using NHibernate ICriteria for pagination

I am implementing a pagination solution using NHibernate ICriteria where I wish to display distinct elements within the page. The ICriteria for this is: Session.CreateCriteria(typeof(Employee), "a") .CreateCriteria("Company", "b") //BUNCH OF JOINS .SetProjection(Projections.ProjectionList() ...

How do I automap a component collection in Fluent NHibernate?

I have a TrackLog that contains a collection of GPS points as a TrackPoint object: public class TrackPoint { public virtual int Id { get; set; } public virtual List<TrackPoint> TrackPoints { get;set; } } public class TrackLog { public virtual double Latitude { get; set; } public virtual double Longitude { get; set; } ...

Example of a simple ASP.NET MVC + NHibernate + Fluent with proper session handling?

I'm new to all of these technologies. I would like to see a simple (not over the top) example of how you would set up a project with these technologies. The most important being the proper NHibernate session handling (using HttpContext). Or we can build off of what I already have. I've seen several examples of one piece or another but n...

nHibernate Linq join support; The method Join is not implemented

I am using the latest nHibernate.Linq 2.1.2. But if I use join in my linq query I will get run time error "The method Join is not implemented". Could someone tell me if join is supported by nHibernate.Linq and if it is supported what is the cause of this error? ...

NHibernate, Log query execution time?

Hi! I configured Nhibernate and log4net to log queries executed by nhibernate. Is there any way to log each query execution time? ...

NHibernate: help to construct query

My domain: class Product { IList<Income> Incomes {get; set;} Category Category {get; set;} } class Income { Product Product {get; set;} int Quantity {get; set; } } I need to query products which Incomes have sum of Quantity > 0. I was able to do this with query: ICriteria criteria = session.CreateCriteria(typeof (Inc...

"Entity Not Mapped" exception when using HQL. Works with Criteria.

Before talking about the problem here's some background: There are 3 assemblies. One containing an Entity class and the problem HQL. Tests. Website. All the tests in the Tests assembly for are passing for the HQL. The exception is thrown in the website. If I use the equivalent Criteria code it works fine in all assemblies calling it...

Can I eager load a property using HQL?

I'm trying to work out how to eager load the customers in the following HQL query: select order.Customer from Order as order where order.Id in ( select itemId from BadItem as badItem where (badItemType = :itemType) and (badItem.Date >= :yesterday) ) There's the usual many-to-one relationship between orders and customers. I'd li...

Transactions in NHibernate - UPDATE then INSERT. What am I doing wrong?

In this sample console app I want to update a row in a table, and then insert another row in the same table. The table is like this CREATE TABLE [dbo].[Basket2]( [Id] [int] IDENTITY(1,1) NOT NULL, [UserId] [int] NULL ) ON [PRIMARY] CREATE UNIQUE NONCLUSTERED INDEX [IX_Basket] ON [dbo].[Basket2] ( [UserId] ASC ) So basi...

NHibernate many-to-many and SELECT N+1 problem

I have 4 database tables (Channel, User, Message, User2Channel) and according entity classes: class **Channel** { int ChannelId {get;set;} int ISet<User> UsersToChannel {get;set;} ... } class **Message** { int MessageId {get;set;} Channel Channel {get;set;} User User {get;set;} ... } class **User**{ int UserId {get;set;} ISet<...

Resolve Method with Unity

Hi Friends, I'm developing an web application with asp.net mvc 2, and I'm using NHibernate (session per request) and Unity (for dependency injection). In my Global.asax I'm managing my ISession something like this: public override void Init() { base.Init(); BeginRequest += OpenNHibernateSession; EndRequest += DisposeNHiber...

Fluent NHibnerate Domain mapping issue

My Domain: public class Person { public Person() { } public virtual int PersonId { get; set; } public virtual string Title { get; set; } public virtual string FirstName { get; set; } public virtual IList<Address> Addresses { get; set; } } public class Address { public Address() {} public virtual int Addre...

Returning null exception on linq statement

There's probably a very simple reason for this, but when hydrating an object I'm keep getting a "value cannot be null" exception: public class MyObject { public MyObject() { } public virtual IList<MemberObject> MemberObjects { get; protected set; } [JsonProperty] public virtual SubObject LastMemberObject...