Subscribe to
Posts
Comments

Had a problem with NHibernate Lifecycle events recently where they appeared not to be firing when I was hitting ISession.Save(entity). After some investigation I finally realised that if you create a new entity, then query NHibernate it may implicitly persist the transient object during a Flush. When it does this any interceptors will be fired at *Query time* thus preventing them from firing when you explicitly call SaveNew. This is by design of NHibernate to ensure the query results are always valid, and is documented here.

Map Tube

I’m not sure how long this has been around, but it’s just popped onto my radar:

MapTube - a place to put maps

It’s a collection of Google Maps overlays most of which display demographics, but this one caught my eye - it’s a map showing the actual location of the London Underground lines, like the Way Out Map.

I love my Mac, but this morning I found the one reason why the glossy UI isn’t always that great - since upgrading to Leopard Apache hasn’t been working on localhost but according to the System Preferences panel all is well.

A quick Google and I found several references to apachectl which is the server control interface. Running “apachectl -k restart” at the prompt returned


(13)Permission denied: make_sock: could not bind to address 10.0.0.1:80
no listening sockets available, shutting down
Unable to open logs

There were 2 clues - the one which I ignored at first about permissions (”i’m logged into an administrative account so it can’t be permissions… doh”), and the reference to the logs. Turns out that on my installation of Leopard the log file folder had failed to be created and thus Apache wasn’t starting.

If you’re having these problems, try the following.

sudo mkdir /private/var/log/apache2
sudo apachectl -k restart

Hey presto everything back under glossy System Preference panel controls once more, and just PHP to get working again.

NHibernate and NOCOUNT

The system i’m working on at the moment recently went into systest and we found a couple of database errors relating which NHibernate was throwing an exception of

Unexpected row count: -1, expected 1

This wasn’t happening on the development system so we took the apparently faulty database from systest and ran it in dev. No errors. This all pointed to an environment issue and after a little checking we discovered that the NOCOUNT setting was different between each database server.

But hang on - when we create the ISession we were creating an IDbCommand and setting NOCOUNT OFF, surely this was enough? Running a SQL profiler I spotted sp_reset_connection commands being executed almost every other statement from NH. This was resetting the NOCOUNT setting and thus it inherited it from the server setting all the time.

Comparing another system’s NH provider versus the one in this system, and I discovered a subtle difference. System A creates an IDbConnection itself and passes it into NH, whereas system B lets NH generate its own connection. It seems that the ConnectionProvider in NH tracks where the connection was created and aggressively releases it if it was internally created.

So my advice is always pass your own connection to NH which allows for better testing and removes the possibility of this happening. Spring.net was a very quick candidate for doing this DI for me.

UPDATE: Since writing my post, i’ve found that providing your own connection prevents NHibernate using the second-level cache so the better solution is to write your own implementation of ConnectionProvider which calls the NOCOUNT OFF on new connections and wire that up in your .config file. Here’s my implementation.

UPDATE 2: I’ve been writing a Linq to SQL app this week, and it turns out that it also requires NOCOUNT OFF, otherwise you get a “Row not found or changed” exception of type ChangeConflictException with a single ObjectChangeConflict object, which has 0 MemberConflicts!

The recent ‘Take 2′ Apple TV update has saved the small square box under my telly from EBay. 1080p output, rental HD movies, and now streaming internet radio have given it a real lease of life.

Now I realise that it’s meant to be just a media extender, but as it’s just a Mac under the hood i’m hoping we get an SDK soon, then we could have a few new features like

- RSS browsing sync’d with Newsgator with an iTunes-sourced soundtrack
- London Underground line information without needing my Mac or digital text
- Optionally playing music without displaying the flipping artwork

Frozen Grand Central Station

This is surreal. From Improv Everywhere… “On a cold Saturday in New York City, the world’s largest train station came to a sudden halt. Over 200 Improv Everywhere Agents froze in place at the exact same second for five minutes in the Main Concourse of Grand Central Station.”

EyeFi

From CoolHunting

Eye Fi card

“By installing Eye-Fi software on your computer and using the 2GB card in your camera in place of a regular SD card, you can use your home WiFi network to automatically upload photos via easy-to-use software. It’s really that simple.”

Slight downside that you have to install software - I hope this software can be downloaded for free from their website for those times you’re in a cafe, or perhaps the software only enables extra features like uploading to Flickr etc.

Bangkok market on trainline

Wifi Speed

Home WiFi has been playing up a bit recently with poor performance. After some manual tweaking of the channel based on the results of iStumbler (or NetStumbler for you PC folk) with no achievement, I found this discussion of channel selection.

Deserialising to IList

Having upgraded the website I work on to .net 2.0, one of our console apps failed whilst talking to a webservice on the site. We’d not changed anything on either the console app, or the website other than upgrading the website to 2.0.

The error message was “global:System.Collections.IList cannot be deserialized because it does not have a default public constructor”. This makes a lot of sense and it turns out that the class being serialised contains a public IList property. Changing this to a concrete type solved the problem.

So the question is… what was the deserialiser in 1.1 doing? how did it know which concrete type to deserialise to?

« Prev - Next »