nhibernate

Business rules validation in NHibernate Validator

Is it possible to define a validation method (for businbess rules validation) that will be used by NHibernate.Validator? I mean something that exists in EntLib: [HasSelfValidation()] public class SomeClass { //... [SelfValidation()] public virtual void DoValidate(ValidationResults results) { //... } } ...

Error building SessionFactory in nHibernate.

I am getting an "ArgumentOutOfRangeException" on parameter index whenever I try to instantiate a session factory in nHibernate. The error comes from a procedure deep in the bowels of nHibernate. I can post the stack-trace of the error if that would help. This is on a fresh project with a pretty simple three tier architecture. The data l...

NHibernate: HQL and UserTypes as query paramaters

I'm using a database that has a weird date format. I wrote a UserType to transfer standard .NET DateTime to/from the weird format and it works fine. I've normally used ICriteria queries but decided to try IQuery using HQL on this project. I ran into a problem that query doesn't translate parameters to the appropriate UserType. eg: I...

Do you think of the database or objects first when building applications?

When you think about building an application, say for the web, and it uses a relational database, do you think about the database first and then putting you app as a front end or do you think of your program and objects and how a database can store those. I'm trying to change the way I think but it hasn't clicked (I'm not sure I'm even ...

NHibernate and Multiple Database backends - Architecture question

Hello, I have a project that is supposed to run on different (at least 2) databse backends, so users can choose (currently between MSSQL and SQLite). I've just started learning NHibernate, following the tutorial on NHForge. Now, my current Architecture looks like this: MyProject.DAL Contains NewsItem and INewsItemRepository. NewsItem...

NHibernate many-to-one relationship deleting parent only

I have a many-to-one relationship between objects Product and Supplier. I need to be able to delete Supplier without deleting the Products that belong to it. Here is a simplified version of classes: public class Supplier { public virtual IList<Product> Products { get; protected set; } } public class Product { // Product belong...

NHibernate: a reverse version of in()?

Hi all, I am trying to perform what I can only describe as the reverse version of IN() using the Nhibernate Criteria.. Rather than saying the value stored in the property is in the list/collection X I want to say, this value X (an ID) is in the list which is a property of the object. Any help appreciated, I can try to explain better...

Lazy loading a portion of a record with NHibernate.

I'm not sure how to explain this. So here goes... I'm trying to fit the method for lazy loading blobs as described here but I'm stuck with only one table. I have a schema (fixed, in a legacy system) which looks something like this: MyTable ID int Name char(50) image byte This is on Informix, and the byte column is a simple ...

Nhibernate criteria query inserts an extra order by expression when using JoinType.LeftOuterJoin and Projections

Why would this nhibernate criteria query produce the sql query below? return Session.CreateCriteria(typeof(FundingCategory), "fc") .CreateCriteria("FundingPrograms", "fp") .CreateCriteria("Projects", "p", JoinType.LeftOuterJoin) .Add(Restrictions.Disjunction() .Add(Restrictions.Eq("fp.Recipient.Id", recipientId)) ....

NHibernate joined-subclass

Hello, I'm trying to implement class inheritance hieararchy with NHibernate and SQL server. I made it work fine with the table per hierarchy strategy (one table and several subclass elements in the mapping file). However the table per subclass strategy (N + 1 tables and N joined-subclass elements in one mapping file) makes more sense i...

Why can't I set ReadOnly on a Fluent NHibernate References() mapping?

In Fluent NHibernate, References() returns an object which doesn't support the 'ReadOnly()' method. I'm trying to create this sort of mapping (i.e. one where an update is not propagated to the referred item): <many-to-one update="false" insert="false" name="DestinationSheet" column="DestinationSheetNumber" /> On normal (map()) mappi...

At a loss, how to map two classes in Nhibernate

Please forgive the clumsy question (if you can figure out a better way to word the question feel free to edit away). I have two classes SupportTicketCategory and SupportTicket (respectively): public class SupportTicketCategory { public SupportTicketCategory() { } private int _supportTicketCategoryID; public virtual ...

Using Sqlite InMemory DB for unittesting MSSQL-DB

Hallo, i am trying to implent this solution NHibernate-20-SQLite-and-In-Memory-Databases the only problem is that we have hbm's like this <class name="aTable" table="[dbo].[aTable]" mutable="true" lazy="false"> with [dbo] in the tablename because we are working with mssql and this does not work with Sqlite. i found also this postin...

Fluent Nhibernate composed entity, specify parent key

In this question I was answered hot to map a composed entity from the primary key of the table. So given: public UserMap() { WithTable("aspnet_Users"); Id(x => x.Id, "UserId") .GeneratedBy.Guid(); Map(x => x.Name, "UserName"); Map(x => x.Login, "LoweredUserName"); WithTable("LdapUsers", m => { m.Map...

NHibernate: how to map a Point ?

I have a class which contains a collection of Points (PointF's rather). I want to be able to persist instances of that class using NHibernate. My class looks somewhat like this (simplified): public class MyClass { public IDictionary<string, PointF> Points = new Dictionary<string, PointF>(); public void AddPoint( location, Poi...

Can I use NHibernate to store an object in xml serialized form?

Say I have a class like this: public class MyClass { public int Id { get; set; } public DateTime Date { get; set; } public string String1 { get; set; } public string String2 { get; set; } public string String3 { get; set; } public string String4 { get; set; } } Is it possible to get NHibernate to store it in t...

NHibernate Named SQL Query and Dynamic Where clause

We have a legacy db that I am mapping to NHibernate. We have some calls that accept a Predicate object that generates a where clause for a table/view entity. We were able to modify the Predicate to return Criterion and use it with the table entity. This method does not work with the view entities, because the mappings return an error ...

storing images in db and map them with nhibernate

how to store images in db and map them with nhibernate ...

Does nHibernate Escape strings?

From a user report, 'when editing foo. textboxBar allows special characters which produce a warning .net error on save ' textboxBar.Text is assign to an object and saved using nHibernate <property name="TextboxBar" length="255" not-null="false" /> Thinking it may be nHibernate not escaping strings but can't find it in the docs. Does...

Will nhibernate generate wrappers for my stored procedures?

Hi, Just getting into nhibenate. Will it generate wrappers for my stored procedures? I am trying out constructs product, not sure if there are others out there that might be better? ...