January 2007

Thumbs

To balance my previous post somewhat, besides creating an editor for images, I’m also creating an imagebar with thumbnails. The image bar can be used to drag imagefiles into and to select the image that you want to edit. I have to say that, using ImageIO, it’s really easy to implement this. All you have to do is extend from JComponent and implement the paint() method to have the image drawn. Because of the way Java2D works, there is no need to figure out the coordinates of the image, it’s always relative to the component so you just use (0,0). With some fancy rendering of higlighting when mouse overed and a delete icon that pops when hovering it’s starting to look really nice:

screenie.JPG

ImageEditor
Java

Comments (0)

Permalink

Java2D is teh suck!

I’ve been trying to write a simple applet for rescaling and rotating images prior to uploading them to wordpress, but the way in which Java2D works with images really really REALLY! sucks. There is just no way to easilly get what you want. Right now I’m seriously contemplating just creating all the logic from scratch….

ImageEditor
Java

Comments (2)

Permalink

Hibernate, second level cache and Clustering

So, I ran into a nasty little problem at work when trying to cluster the hibernate second level cache. We were using hibernate 3.2.1 GA and ehcache 1.2 and when replicating the caches between multicast nodes, random classcast exception occured when retrieving an object from secondlevel cache(slc). Turns out that the problem was with the way hibernate stores it’s objects in de slc, by default it stores the attribute values of the properties in an array, this array gets replicated to the various nodes. Normally this would not be a problem, but it seems that the order of the properties as determined by hibernate for persistentclasses (using annotations) is not fixed between SessionFactories. This caused the classcast exceptions, because where one instance inserted a String, the next instance expected a Date or Long or whatever.

We’ve even tested this by deploying the same WAR file on the same machine (same tomcat etc.) the problem will still occur. There is a way around this problem, luckily, it took us a while to find it:

If you set the hibernate property hibernate.cache.use_structured_entries to true, hibernate will use a HashMap to store attribute values by their property name. This way, the retrieval of the properties is guaranteed, even when the order of the properties isn’t. I’m guessing that this problem only affects hibernate when using annotations, since otherwise the order of the properties is already set in the XML, but I’ve not tested it.

Java

Comments (0)

Permalink

Hello world!

Well, it’s taken a long time, but it’s finally here. My Own Blog ™ ! I’ll write about whatever stuff comes to my mind, sometimes I will have a lot to saty, and sometimes I wont. Whatever….

TheBlog

Comments (0)

Permalink