java.net: Unit testing Hibernate-based DAOs

java.net have an interesting article on Unit Testing Hibernate-based DAOs, that are also implemented using Spring DAO support with the HibernateTemplate.

This article is an excellent checklist of steps needed to Unit Test Hibernate based DAOs. There are a couple of interesting points in the code though will not 100% test your persistence due to the default behavior of Hibernate and it’s caching.

These issues are not addressed until the final point in the article (Step 12: The Session must be flushed) – the author should have mentioned this critical point earlier in the article when showing the code to test persisting a new object and retrieving it. Without the flushing and clearing of the session retrieving an already referenced object by it’s id within the same Session returns the same instance of the object from cache (ie a == b). Although this won’t break the JUnit, unless you had read all the way to the end of the article you might have missed this important point. Without the flushing and clearing of the Session (or using a new Session), the retrieval of the newly persisted object will return a reference to the same object, without actually executing any SQL to retrieve it from the database.

JBoss and Microsoft sign agreement to leverage each other’s technologies?

Microsoft and JBoss have signed an agreeement to be able to maximise the performance of JBoss running on Windows platforms.

I bet no-one could have seen that coming. Only up until a couple of years ago Steve Balmer was foaming at the mouth and pronouncing the Open Source software was a ‘cancer of the software industry’. How times change. First came the Linux lab up at Redmond (who knows what it is called internally – the ‘lab of lost opportunities’?), and now Microsoft are embracing and helping out a serious competitor that develops one of the fastest growing Java Application Servers out there today.

Are Microsoft seeing the light, or are they realizing they can’t continue to run scared, that they have to starting playing in the same game to be able to keep up with changes in industry trends, for example, the widespread adoption of Open Source software in favor of expensive commercial software?