NHibernate
There are 7 entries for the tag
NHibernate
Recently I had a problem with the application I’ve been working on. One of entity types in my domain had a property of type uint. Not a big deal, until you want to store it in Microsoft SQL Server database which does not support unsigned types. I’ve been scratching my head for a moment and then I found a solution – let’s map it as long in our database. Since long can represent any legal value of uint, we should be all good, right? So let’s do it. ...
As nice as SQLite is for tests it is very simple database, and it does not have all the options ‘big’ databases provide (foreign key enforcement!). I don’t think there’s much you can do about this issue, but there’s more.
SQLite does not support all the mappings you can have. I bumped into this issue when working with mapping similar to described in this post. Basically when you try to create schema from this mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="ConsoleApplication1"
...
There does not seem to be too much details on how to set up a test environment for NHibernate testing using SQLite. Ayende has a nice post on this, but he does not go into details of how, what and where, so I decided to fill in the blanks, and provide an up to date sample for NHibernate 2.1. Let’s first gather all the things we need: NHibernate (obviously) SQLite binding for .NET get the full version (not managed-only) SQLite itself scroll down to...
There comes a time when you have to store in the database not only pretty objects but also some not so pretty data. For example, let’s take the classical entity – the invoice. Let’s say your application can receive invoice in three ways: by its own frontend, by email in rtf file, and by fax. In two later cases you may have a requirement to store the rtf file and the scanned fax as a proof in the database. How to approach that? Let’s start by sketching our Invoice class: ...
As nice as the example from my previous post was (person having pets) it exhibits a problem. The problem is related to the fact that by their very nature associations in relational databases are bidirectional, whereas in objects they are unidirectional. Here we hit the mythical impedance mismatch.
Often however we want to have a bidirectional association in our object model. Person may have a set of pets, but then each pet has its owner. Then we have another problem. What if we add a pet to person’s pet collection, but forget to set pet’s owner? We’ll get inconsistencies.
The best way...
I’ve been working with NHibernate for the last couple of days, and as I make my way though it, I find out about things, that were not so obvious to me at first, so I decided to post them here, so that someone else can benefit as well. First thing you learn about NHibernate (well ok – first thing I learned about NHibernate, but most of you probably as well) is that it requires you to mark your properties virtual, have parameterless constructor, and pay special attention to your GetHashCode() and Equals() methods. With all...
I really need to come up with filtering strategy, or get some long vacations to go thorough all the good stuff that’s there. Any ideas? How do you handle the discussion groups? Technorati Tags: ALT.NET, Castle, XP, NHibernate