donderdag 30 maart 2006

Low key portraits with a Hasselblad

The past few weeks, I (and my fellow photography students) have been playing with Hasselblad camera's in the studio.

This is a low key portrait that one of my collegue students took from me.





Unfortunately, I was not able to scan the entire picture (it is to big for my scanner), so that I cannot present it here in its original and typical square Hasselblad format.

I also took some very nice shots from other persons, but I'm not going to post them here (yet), since I do not have the permission of those persons to do so.

I really like those Hasselblad camera's. They're great to work with and provide great quality. I even think of buying one (a 2nd hand, because these things are expensive...)

donderdag 9 maart 2006

NHibernate: where's the productivity ?

I've been playing around with NHibernate the past few days, and I've encountered a rather strange bug...

I wanted to perform a rather simple HQL query. I wanted to know the total value of the Orders that were placed by a Customer.
So, I thought that this simple HQL query would do the job:

IQuery q = theSession.CreateQuery("select sum(ol.Price * ol.NumberOfItems)
from OrderLine ol");

However, this didn't work...
This query did work however:

IQuery q = theSession.CreateQuery("select sum(ol.Price) from OrderLine ol")


It appeared that the query (the one with the multiplication in the sum function) that was sent to the database looked like this:

select sum(orderline0_.NumberOfItems*orderline0_.ItemPrice) as x0_0_
from tblOrderLine orderline0_

while NHibernate was then trying to access a result-column that was called x1_0_
This will offcourse not work, since the field has been given the alias x0_0_

After some searching, I've found out that this was a bug that also existed in Hibernate, but has been fixed in Hibernate 3.0.

So, I had to look for an alternative.
The idea came up that I could retrieve all the orderlines that belong to a specific Customer, and then, do the calculation myself.
So, I came up with this HQL query:

IQuery q = theSession.CreateQuery ("from OrderLine ol " +
" inner join Order inner join Customer " +
" where Customer.Id = :custId");

This didn't work as well... An exception was thrown saying that the BY keyword was expected after a GROUP or ORDER. However, I didn't use any group by or order by statements ? Then, I've noticed that I've a class that's called Order, so maybe I had to escape the classname.
However, I couldn't find how to do that (if it is possible), so I've rewritten the query to something like this:

IQuery q = theSession.CreateQuery ("select ol " +
" from OrderLine ol, Order o, Customer c" +
" where ol.Owner = o and o.Owner = c " +
" and c.Id = :custId");

This didn't work as well...
The exception now said:
Could not resolve property:Id of Customer
I found this very strange, since this class has an Id property.
After some research, I found out that the Id did not appear in my hibernate mapping file indeed.
This is, because the Id is used as the 'id' in my mapping file, and, since the Id property is read-only in my class, I use a field access method to set this field. This is specified in my hbm mapping file like this:

<class name="NamespaceName.Customer, NamespaceName" table="tblCustomer">
<id name="id" access="field" column="Id"... >
...


So, what should I do next ? I didn't want to make the Id property of my Customer clas s writable.

I tried to add the Id property to my Customer mapping file, without touching the 'id' element.
So, I've added the Id property to my mapping file, but, since I've introduced the same database column twice, I had to use some attributes:

<class name="NamespaceName.Customer, NamespaceName" table="tblCustomer">
<id name="id" access="field" column="Id"... >
...
<property name="Id" update="false" insert="false">
...


Now I tried to rerun my query. However, retrieving a Customer was already a problem. I received an exception that said that the property value of the Id property could not be set via reflection. Damn.
I really don't want that somebody can set the Id of a Customer via the property...

Luckely, .NET 2.0 came to the rescue. In .NET 2.0, you can define different access-modifiers on your property getter and setter. So, my Customer class looked like this :

public class Customer
{
private int id;

public int Id
{
get { return id; }
}
}

I've changed this to

public class Customer
{
private int id;

public int Id
{
get { return id; }
private set { id = value; }
}
}


And this finally did the trick...

I've spent something like 2 hours in getting something simple like this to work in NHibernate. With a self-written Data Access Layer, this would have taken me something about 10 minutes I guess, to implement this functionality.
Conclusion: there's a lot of work to be done on NHibernate before I will really call it 'productive'. However, it is a promising project though.

For more information about my quest, I refer to a topic I've opened regarding this issue on the NHibernate support forum.

maandag 6 maart 2006

Troubles with Visual Sourcesafe, looking for alternatives

Today, I've encountered some rather unpleasant moments with Visual Sourcesafe. Around 4 o'clock, it appeared that my VSS repository was corrupt. :(
Trying to restore the latest backup didn't succeed as well, since there was a problem with that tape. :(

This means I had to use the backup of last thursday... Luckely, after some extra work, I've been able to restore most of my work.

However, I do not want to experience these problems again, so, just like Sam Gentile, I'm going to ditch VSS, and look for an alternative.

At this moment, I've 2 options in my mind:

  • SubVersion

  • Sourcegear's Vault


Some time ago, I've downloaded a trial version of Vault, and it looked ok to me. However, I've heard that it doesn't integrate very well in VS.NET (haven't tried that yet).
On the other hand, we have Subversion, however, I haven't worked with it before.

Anybody who has experience with one of these 2 systems and wants to share his/her opinion ?

zondag 5 maart 2006

Formula One: The new season is coming...

At last, after a long winter of F1-less Sundays, the new Formula 1 season will start next sunday.
I find it always interesting to see during the first race of the year which teams have done their home-work, and will be the teams to beat during the season.
I bet that, for the 2006 season, Renault and Honda will be the favorites for the World Championship with Ferrari and McLaren on their heels.

Who will be world champion ? Will Alonso extend his title, or is Schumacher able to fight back ? Can Raikonnen, who has been close to catch the title last year and in 2003, finally clinch the championship ?
However, I think that Jenson Button also has a chance to win some races this year...

All questions that will be answered during the next months, and the first race in Bahrein should already give a strong indication of who holds the best cards.

Anyway, I'll be supportering for Kimi Raikonnen and Jacques Villeneuve. I just like the driving style of these 2 guys.
I hope that it will be an interesting season, with a lot of exciting duels on the track.


To get into the F1-mood, here (18mb) is a video-clip of one of the most exciting duels in F1 history.
This video shows the last 3 laps of the 1979 French Grand Prix which was held in Dijon. René Arnoux and Gilles Villeneuve are contending for 2nd place. René Arnoux is driving a Renault Turbo (with a defect Turbo), while Villeneuve is driving an atmospherical Ferrari with worn out tires. (You'll see the reason for those worn out tires...). The commentary is from the legendary Murray Walker.

woensdag 1 maart 2006

It's been a while...

It's been a while since I've made a post on my blog. I'm currently busy reading the book Agile Software Development and I'm also playing with NHibernate a little bit.
I am thinking of creating a little tutorial / Quickstart about NHibernate and post it here, but I'm not sure yet. It is a lot of work, and takes some time... :)