I’ve upgraded to WordPress 2.5

The latest version 2.5 of WordPress was released yesterday and I’ve just upgraded Noulakaz.net.

I use a number of plugins and I had a small issue with one of them, Alex King’s Popularity Contest, which kept generating fatal errors when activated. Fortunately, I came across a simple one-line fix. This is where open source software really shines compared to its proprietary cousins…

Dear readers, please spend a few minutes testing the weblog and don’t hesitate to contact me if you notice any issue. Thanks.

Hibernate: a powerful enterprise Java technology

Despite my interest in all things Ruby especially Ruby on Rails, I’ve decided to have a look at some powerful enterprise Java technologies. As you know, last semester, I taught Software Architecture at Masters level and I’ve become fond of using Java once more (which I used for the lab sessions).

Of course, the fact that Java is now opensource and so are most of the most interesting Java libraries and frameworks has also influenced me.

Anyway, today I’ve spent some time with Hibernate which is a framework to map plain old Java objects (POJOs) to relational databases. Basically, it allows a programmer to write a database application using normal object-oriented development methodologies and without writing a single line of SQL.

The first step is to write a POJO. It does not have to be a Javabean (Hibernate is perfectly happy if attributes don’t have getters and setters). For instance, this will do:

public class District {
    private Integer id;
    private String name;

    public District() {
    }
}

Then write a mapping file which is basically an XML which describes how each attribute will be stored in a relational database. In many cases, this is trivial:

<hibernate-mapping>
    <class name="datasource.District" table="DISTRICTS">
        <id name="id" column="DISTRICT_ID" access="field">
            <generator class="native" />
        </id> 
        <property name="name" column="NAME" access="field" />
    </class>
</hibernate-mapping>

In case you have a many-to-one or a many-to-many association, have a look at chapter 7 of the Hibernate documentation. It’s explicit enough.

Configuring Hibernate to connect to your database is easy (I use MySQL 5.0 with the latest Connection/J JDBC driver). Just follow the official tutorial. The important part is:

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

Finally, write a small toy application in Java to force Hibernate to create the database schema:

package hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class CreateDatabaseSchema {
    public static void main(String[] args) {
        Session session = null;
        
        try {
            SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
            session = sessionFactory.openSession();
            session.flush();
            session.close();
        }
        
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

Tomorrow, I’ll use the Spring framework to decouple Hibernate from my application. I’ll surely indulge in some dependency injection. Yummy!

(Muhammad Ali picture courtesy of this website)

Typical Mauritian food

We were at Péreybère on Sunday as delightfully narrated by Gavin on his blog. There, after some swimming and kayaking, we indulged ourselves (twice!) in some “glaçon rapé” (pictured above). It’s basically, in case you are not from Mauritius, ice served with different kinds of syrup.

I may be wrong but I think “glaçon rapé” is typically Mauritian. I don’t remember seeing something similar in other countries.

Another example might be “mine-bouillie carri gros-pois” (boiled noodles with beans curry). Granted, many have never tasted it. But I can tell that this bizarre combination tastes very nice. Just ask Kavi, Begum and Christina who are converts now!

Yet another example is the “dholl puri” which is one of the staple food of many of us at lunchtime. It’s a kind of pancake with a mixture of different curries and chili. I didn’t see anything similar when I visited India.

Can you think of other examples of food only found in Mauritius?

(“Glaçon rapé” photo by G@V!N)

Are we worthy Mauritians?

Paul Graham, one of my heroes, has written Six Principles for Making New Things where he offers the following (timeless) advice when creating something new:

  • I like to find simple solutions
  • to overlooked problems
  • that actually need to be solved
  • and deliver them as informally as possible
  • starting with a very crude version 1
  • then iterating rapidly.

I wonder if this recipe can be used to create a new Mauritian society as the current one has so many warts (according to me).

Reginald Braithwaite comments: “[T]he negative folks are the most vocal, while the positive folks are trying [...] instead of whining”.

We should really focus on those real but overlooked problems in our country. One example is communalism. Of course, everyone agrees that communalism exists but so many of us think that it is a feature of Mauritius instead of being a problem.

Another problem area is education. The world is now a knowledge society. And those with knowledge have power and wealth whereas those who don’t are modern slaves. Transforming our education system into something that is “world-class” will take 10 years at least and I’m not sure that we have that kind of time left. But we really should try.

We should really stop wasting time with “problems” that are not really important. The best example I can think of at this time is the democratization of economy. As explained by Paul Graham, the pie fallacy is a fallacy!

Mencius Moldbug points out that the world is full of “bureaucrats [who] build empires which churn out meaningless solutions to irrelevant problems”.

Paul Graham says that “if you deliver solutions informally, you (a) save all the effort you would have had to expend to make them look impressive, and (b) avoid the danger of fooling yourself as well as your audience.”

If you know me, you’ll know that I am a big fan of informality. Tomorrow, we’ll have very formal flag raising ceremonies everywhere in the country but I’m afraid most of us (including myself maybe) will focus more on the Coca-Cola and the small cakes…

Antoine de Saint Exupéry, the famous writer and airplane designer, once said: “You know you’ve achieved perfection in design, Not when you have nothing more to add, But when you have nothing more to take away.”

Happy 40th birthday to all of you, my dear fellow Mauritians.

Football in Mauritius

I know. I know. The state of football is not that great in Mauritius. And, to be frank, I don’t even know the names of the teams in the 1st division.

I’m writing this blog entry because I got a mail from someone called Piotr Chmielewski (he is from Poland) who writes about football on a website called Afryka. He is currently writing about Mauritian football and would like to have the following information:

  • What is the best Mauritian team?
  • Which team has the largest number of supporters?
  • Who are the stars of Mauritian football?
  • Who is the biggest star?
  • What is the current Mauritian national team?
  • Who are the national team players playing abroad?
  • Who are those playing locally?
  • What do you think of our chance to qualify for the 2010 African Cup of Nations?
  • Can Mauritius beat Cameroon?
  • Can Mauritius beat Cape Verde?
  • Can Mauritius beat Tanzania?
  • Anything else interesting about Mauritian football.

Please feel free to comment. I will consolidate the information I get and send it to Piotr.

My personal opinion

I don’t know anything about current teams and players. The biggest star might (still) be Jean-Sébastien Bax. I think we have a chance to qualify for the second round of the ACN 2010 qualifications as one of the second best. We will get beaten by Cameroon (naturally) and beat both Cape Verde and Tanzania at home. We will also be beaten by Cameroon away and we will draw with both Cape Verde and Tanzania on their home soils.

As for the “anything else” part, my feeling is that it’s a pity that football is in such a bad shape here. Football is (by far) the largest religion on the planet and I find it sad that most of us know more about Barnsley than the Mauritian National Team…

About the photo above

May I introduce to the world the next Liverpool striker, my son Kyan :-)