nhibernate

NHibernate - How to store UInt32 in database

What is the best way to map UInt32 type to sql-server int type with NHibernate. The value is a picture width/height so negative value are not make sense here. But maybe I should use int because NHibenate doesn't support unassigned ints. ...

Short-circuit evaluation and LINQ-to-NHibernate

It seems that LINQ-to-NHibernate and LINQ-to-SQL does not support short-circuit evaluation in where clause of query. Am I right? Is there any workaround? May it be added to next versions of LINQ-to-NHibernate and LINQ-to-SQL? for more information plz see followings: http://stackoverflow.com/questions/772261/the-or-operator-in-linq-w...

NHibernate does not create Tables

var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(<ClassName>).Assembly); new SchemaExport(cfg).Execute(false, true, false, false); The above piece of code is supposed to create a database Table with name But it is not creating... Can someone help me out on this... It is very urgent... ...

how to prevent NHibernate running an "Audit Login" on configuration

When i configure NHibernate it seems to do an Audit Login -- network protocol: LPC set quoted_identifier on set arithabort off set numeric_roundabort off set ansi_warnings on set ansi_padding on set ansi_nulls on set concat_null_yields_null on set cursor_close_on_commit off set implicit_transactions off set language British set dateform...

NHibernate Named Query

Hi, I'm trying to learn about SQL named queries using NHibernate and I have the following code. The issue is that I get the following error : "Message: No value given for one or more required parameters." when I try to test the code from MBUnit. <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2...

Spring.net with NHibernate and the "No Hibernate Session bound to thread error"

Hi, I am attempting to use spring.net and nihibernate for my data layer. I have a simple DAO object that includes the following code: [Transaction] public long Save(Request entity) { return (long)CurrentSession.Save(entity); } Whenever this code is called I get the following error: "No Hibernate Session bound to thread, and ...

alternate database schema queries in nhibernate

Hi, I am working on an asp.net business application and using nhibernate. My objective of using nhibernate is to minimize/avoid application porting effort on different databases(Oracle, SQL Server, Postgres etc). I have a scenario where i have to dynamically check the database table schema and build some functionality on it. First thing...

How to force NHibernate not to update all objects in collection

Hi guys. How to force NHibernate not to generate UPDATE for each element in collection if I change only one element of that collection. Here it is: internal class Master { private int _id; public string Name { get; set; } public ISet<Slave> Slaves { get; set; } public Master() { Slaves = new HashedSet<Slave...

NHibernate Lazy Initialized collection on WCF Wire

Hi, My object looks something like this: class { int a; object b; IList<string> c; } All the fields are getting populated from the database and the collection is getting lazy initialization which is desirable. Now, my problem is that I want to send this object to the web service. But since the collection is lazily loaded...

How to use native Sql for Insert and Update in Castle Active Record?

How to use native Sql for Insert and Update in Castle Active Record? There are sample for using Select query here http://www.castleproject.org/activerecord/documentation/trunk/usersguide/nativesql.html But I can't find any sample for Update and Insert. Update: Basically I am looking for a support for Update/Insert query like this. <...

Convert .NET Ticks to SQL Server DateTime

Hello all, I am saving in my DB a TimeSpan (from .NET) value as BIGINT in SQL Server (saving the Ticks property). I want to know how to convert this BIGINT value to a DATETIME value in SQL Server (not in .NET). Any ideas? Cheers EDIT: I am using NHibernate to map a TimeSpan property I have, and it persists the Ticks property. I use i...

How to associate static entity instances in a Session without database retrieval

I have a simple Result class that used to be an Enum but has evolved into being its own class with its own table. public class Result { public static readonly Result Passed = new Result(StatusType.Passed) { Id = [Predefined] }; public static readonly Result NotRun = new Result(StatusType.NotRun) { Id = [P...

How can I stop nHibernate from helpfully setting a date value on a non-null object field when the underlying database field value is null?

I read with excitement the first article that popped up in google -- it was exactly my problem. I have an object model with a non-null date field, but the underlying database field was nullable, and had a null value. It was a DateTime. nHibernate set the value to .Net's Date.MinValue, then tried to save it back, yielding an error. Th...

Complex Ordering with NHibernate Criteria Queries

Came across something like this today, and was wondering if there was an equivalent way to solve it in criteria queries. Basically, there is a table, and this table has two nullable string fields (foo and bar). We wish to sort by the aggregate of these. string concatenation (order by foo + bar desc) returns null if one of the values is...

NHibernate reuse join table in many-to-many association

I have two domain objects: Product and ProductDictionary, which are both abstract classes and they both have many concrete subclasses. They are connected via many-to-many association. I would like to reuse one join table for all associations between Product and ProductDictionary subclasses, because I don't want to polute my DB with unnec...

Stange column name appearing in nHibernate generated SQL

For some reason the following mapping seems to be creating me a very strange column name that I cant find anywhere. There error occures when trying to load the Events collection which is defined as a IList<Event> <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="JeanieMaster.Domain....

NHibernate query problem

Hi all, these are my entities (simplified): public class IdentificationRequest { private int id; private ICollection<IdentificationRequestStateHistoryItem> stateHistoryItems; public virtual string Id { get { return id; } private set { id = value; } } ...

Is linq2nh ready for production?

It is asked before but that was one year back. I would like to know if it is ready for production now? ...

AutoMapper : Map a many-to-many association into a DTO (Is flattening of collection items supported?)

Hi! I have a many to many association between a Team and an Employee. public class Employee : Entity { public virtual string LastName { get; set; } public virtual string FirstName { get; set; } public virtual string EMail { get; set; } public virtual IList<LoanedItem> LoanedItems { get; private set; } public virtual...

Why can't I reference child entities with part of the parent entities composite key

I am trying to reference some child entities with part of the parents composite key not all of it, why cant I? This happens when I use the following mapping instead of that which is commented. I get the following error Foreign key in table VolatileEventContent must have same number of columns as referenced primary key in tabl...