nhibernate

Best mapping on a messed up DB

Hi there! We are trying to switch our project to NHibernate and i'm having this one problem: I have two similar tables in my DB: T_CATS (ID, NAME, TYPE) - All NUMBER types, T_MISC(ID, NAME, PARENT): This table is an old table that we can't change.. It houses a number of independent ENUMS (I Know the optimal way is to store each enum in a...

Saving multiple child entities in NHibernate, at once.

I'm getting the "Save unsaved transient entities" error in NHibernate. I have an aggregate root, neighborhood that contains addresses and person, here's some quick pseudo code to explain the relationship: public class Neighborhood { public virtual int Id { get; set; } public virtual IList<Address> Addresses { get; set; } } public...

What the options are for mapping between the DataModel and the domain model with a Column datasource?

We are currently using SQL Server with Nhibernate as the ORM. We are considering moving to NoSQL Column Datastore. What are the options are for mapping between the DataModel and the domain model with a Column datasource? ...

nhibernate and nested transactions

I know that nhibernate doesnt support nested transactions. Let's say that I got something like this: UserService.BeginTransaction (on current session) UserService.Save UserService->FeedService FeedService.BeginTransaction (on current session) FeedService.Save FeedService.Commit (on the returned transaction in #3.1) UserService->Add...

How to keep long running NHibernate Session data consistent?

I have NHibernate sessions cached in the ASP.NET session. I came across a situation where a user edited an object so it's in their first level cache in the ISession. Another user then edited the same object. At this point User1 still sees their original version of their edits where as User2 sees the correct state of the object? What i...

Can you change from a base class to a joined subclass type in nhibernate?

I have document scanning system where several types of documents are scanned. Initially, the document has no information when its scanned, then they get classified and additional information is entered for them in a second step later. So, I have a base class called Document, and subclasses for each type with their respective metadata lik...

How do I get the entity type on an object that may be a NHibernate proxy object?

I have a base class DomainObject for all my business objects I am using with NHibernate. It contains the Id property. public abstract class DomainObject { public virtual int Id { get; private set; } } I would like to write an IEqualityComparer to compare my domain objects. If two objects have the same Id and are the same kind of...

nhibernate +fluent +mapping

Hi all. I have a table http://img36.imageshack.us/i/beztytuuszxq.png/ and mapping: public class CategoryMap : ClassMap<Category> { public CategoryMap() { Table(FieldNames.Category.Table); Id(x => x.ID); Map(x => x.Name).Not.Nullable(); Map(x => x.ShowInMenuBar).Not.Nullable(); References(x...

Using NHibernate for DotNetNuke Modules?

I'm thinking of adopting a more Domain-Driven-Design approach to DotNetNuke module development and would like to consider using NHibernate as an OR/M layer. Does anyone have experience using NHibernate with DotNetNuke? I've used SubSonic and EntitySpaces, but not NH. UPDATE Sorry, I should have been more clear. Is NHibernate capable ...

Setting expiration on cached entities with SharedCache and Nhibernate

Hi guys, I have an MVC webapp that I'm putting together now. A second app publishes data to a database which my webapp reads from. I am using SharedCache as a cache provider for my NHibernate and I wish to assign "expirations" to my entities (so I can guarentee a level of freshness of the data) - and knowing that some entities are rare...

How do I enable "prepared statements" in NHibernate using SQL Server 2005 and how do I verify it?

My configuration looks like this: <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="kvws.kist.suche.dbadapter.nhentities"> <!-- Driver --> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> <property name="dialect">NHibernate.Dialect.MsSql2005Dial...

Cascade insert on one-to-many with fluent NHibernate

Hi, I have two classes mapped using fluent NHibernate - User and a UserRoleAssignment. An User has many UserRoleAssignments. Here's the relevant map for user: HasMany(x => x.Roles) .Table("UserRoleMap") .Cascade.SaveUpdate(); And for UserRoleAssignment: Map(x => x.User_Id); As you can see, I'm only referencing from User to UserRol...

NHibernate 2.0 mapping a composite-id inside a composite-id

I have a table1 TAS with: <class name="TAS" table="NCPTB016_TAS"> <composite-id> <key-many-to-one column="NU_MACRO_PROCESSO_007" name="MacroProcesso"/> <key-property column="NU_TAS" name="Id" /> </composite-id> ... //and some other properties And i have a table that is: <class name="STAS" table="NCPTB017_STAS"> <composite-id> <...

NHibernate TransactionScope problem with Oracle 11g

The following code snippet works fine with SQL Server 2008 (SP1) but with Oracle 11g the call to session.BeginTransaction() throws an exception with the message ‘Connection is already part of a local or a distributed transaction’ (stack trace shown below). Using the '"NHibernate.Driver.OracleDataClientDriver". Has anyone else run into ...

Getting NHibernate session to see uncommited, external ADO.NET changes within TransactionScope

I have some code that does something like this: public void DoDatabaseWork() { _repositoryIDontControl.SaveSomeStuff(objectThatNeedsStuff.Stuff); using (var session = ... ) { session.Save(objectThatNeedsStuff); } } The crux here is that within my NHibernate mapped data model I have an object that references anothe...

Managing entities in NHibernate 1st level cache

What's the proper way to manage persisted entities in the 1st level cache during thread/session lifetime? Actually, there is only one or two persisted instances per thread (session) that should be present at all times, for referencing them from other (transient) entities before saving. Since I need to clear the session cache every once ...

Fluent NHibernate hasmany save inser null value

hi guys, i'm new to nhibernate so maybe the response depends on my lack of knowledge. I created these two tables: (sorry for italian language, i hope you can understand withouth any problems). Then, i have these object in my model: [Serializable] public class Profilo { public virtual int Id { get; set; } public virtual stri...

Howto ensure objects are lazy loaded with (Fluent) NHibernate?

I have an application using Fluent NHibernate on the server side to configure the database. Fluent uses Lazyloading as default, but I explicitly disabled this as this gave me problems when sending the objects to the client side. Obviously the client can't load the objects lazily as it doesn't have access to the database. Now I try reen...

Why does Id altered from 1 to 1 happen using NHibernate

I have a mapping like this <class name="UserFileSummary" table="UserFile" lazy="false"> <id name="FileId" column="UserFileId" type="int"> <generator class="identity" /> </id>... and a property in the c# object like this public long FileId { get; set; } What I don't understand is why when I get an instance using var my...

Repository Pattern and Data Access

Hello All, I am trying to get into a project with ASP.NET MVC and NHibernate ( Newbie) and looking for faster data access from DAL. my solution will be roughly asp.net mvc ------ Business Layer - DataAccess Layer ----------All supported by Infrastructure layer ---------------- My project is to do with classifieds and community s...