Friday, March 20, 2009

Applications meme

I usually don't take part in these kind of meme games (actually I have never) but this time I thought I could make an exception. Not that this meme is less silly or less absolutely useless than others but for some strange and unexplained reason I found it interesting to try and answer those questions about software I use. So here it is:

1. Which desktop manager do you use more often ?
I use Gnome just because it is the default in Ubuntu and experience has taught me to keep the defaults otherwise trouble is lurking in the shadows.

2. Which desktop application you would not like to see implemented again on linux? And why?
Normally, I wouldn't answer this one because I couldn't care less. At the very last moment though I remembered how annoying it is to have 4 or 5 different media players on my linux machine, each one designated to play a certain type of files. Plz don't create another one. Instead try to make one of the existing ones play everything.

3. Which desktop application you definitely would like to see implemented on linux? Describe it briefly or point out to a similar application.

A decent application for synchronizing my mobile device (phone or other) with evolution or the google calendar.

4. Write the name of the last project (not the very best, the last!) that made you wish to thank their developers so you can thank them now!

The scrobble function in MediaPortal :-) I know it 's a windows application but the question doesn't say it has to be linux.

5. (Optional) Link the blogs of 1-3 people you’d like to take part to this meme. (no more than three). you can skip this question if you like.

What? You mean the others were mandatory?

Friday, March 13, 2009

The case of the WrongClassException

Yesterday, one client reported a strange bug in his application. It was an org.hibernate.WrongClassException during loading of some pojos from the database. I should mention here that the application is EJB3-JPA based with SmartGWT for the front-end. The exception was thrown when trying to load a specific object of class A and hibernate reported that the object was already loaded in the session but it was of the wrong class (class B). After playing around the database and the pojos annotations I saw that the two classes were subclasses of a common class and that the @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) annotation has been used on the parent, meaning that the two subclasses were mapped onto separate tables. I luckily remembered that in that case the primary keys have to be unique among the two tables even though we are talking about separate tables, otherwise hibernate will get confused when an object from table A is already loaded and it tries to load an object from table B with the same id. It thinks that the object is already loaded but it is of the wrong class. The odd thing in my case was that the two tables actually had different keys!!! What had happened as I discovered later was that the client had added some lines in one of the tables without caring about the key uniqueness between the two tables, thus leading to the WrongClassException problem.

Conclusion: Never allow the client touching the database!!!