Thursday, January 31, 2008

Minor JAXB gotcha with Java 6

I hit a small issue today with JAXB and Java 6. It turns out that I was using JAXB 2.1 but Java 6 "prefers" JAXB 2.0. I found some helpful information here.

Tuesday, January 22, 2008

Let Hibernate generate pluralized table names

On my little home project I am using annotations-based Hibernate persistence. As a personal preference I like table names to be pluralized (Call it Rails-inspired). Unfortunately, Hibernate does not provide any support for such a feature and therefore I always ended up specifying the table columns explicitly:

@Entity
@Table(name="jobs")
public class Job implements Serializable {


However, there are hooks to change the default Hibernate NamingStrategy implementation. This means, if you don't provide the @Table annotation then the class name maps directly to the table name.

In fact Hibernate comes with 2 naming strategy implementations out of the box:

Well, on Java.net I came across the Inflector project, which generates the plural of provided nouns. Using it could not be simpler:

String result = Noun.pluralOf(“cat”) ; // = cats

As a result of that find, I created my own class ImprovedPluralizedNamingStrategy which uses ImprovedNamingStrategy as a base. I refactored the contained method classToTableName() so that it returns a pluralized version of the class name.

Also, if you like to know more on how to configure Hibernate naming strategies when using Spring, check out this blog.

What I have done is certainly not production ready but it shows that adding your custom naming strategy to Hibernate is fairly easy to accomplish and helps reducing annotation clutter in my classes.

Thursday, January 17, 2008

Learning Scala

Since the Java Posse has been talking about Scala a lot lately (E.g. episode 155), I felt compelled taking a closer look at Scala myself the last couple of days. Scala is a functional programming language that runs on top of the Java Virtual Machine (JVM). While it has its own interesting syntax-twists it is certainly easier to grasp for Java developers than for example Ruby (Purely from a syntax perspective). You can find more information on the Scala website.

I have not done much, yet. I downloaded it, installed the Eclipse plug-in and went through a good portion of the official Scala Tutorial. I also read “First Steps to Scala” at artima.com.

Tuesday, January 15, 2008

Aprender español en Atlanta

Hoy empecé mi próxima clase en la Asociación Latinoamericana aquí en Atlanta. Actualmente estoy en nivel 10. ¡Solamente 2 más niveles!

Friday, January 11, 2008

Java and the Brazilian Healthcare System

One thing I forgot to mention in my previous blog entry about the Sun Tech Days in Atlanta was the Q and A session with James Gosling. One of the questions was: In his opinion what is the most impressive/interesting Java application he came across and James started talking about the Brazilian Healthcare system, which is running a Java based platform.

Following James, all you need in Brazil is a healthcare card. The whole system is paperless. For example if your doctor gives you a prescription you still only need your healthcare care when showing up at the pharmacy. When going to a different doctor, (s)he just looks up your records in the system.

The system also handles some interesting requirements: names and addresses are optional. For example there are people living the in Amazon forest with changing locations. Also, there are indigenous people that consider a person’s name personal and thus won’t share it with their doctors.

Some quick searching using Google produced the following interesting looking links:

http://www.infoq.com/articles/Brasilian-Healthcare-System

http://java.sun.com/developer/technicalArticles/xml/brazil/

I may spend some time over the weekend reading those articles. Maybe we can implement a similar system in the US???

Sun Tech Days Atlanta

It has been a long day. Nevertheless a really good one – We had Sun Tech Days here on Atlanta and I got the chance to attend the conference today. The whole event had started at 9am and I was able to leave shortly after 8pm. This was a great event and the best thing – it was completely free (including breakfast, lunch, cake, beer/wine and of course T-shirts)

The presentations were really good for the most part. The day started with the keynote speech given by Jeet Kaul speaking about the latest developments at Sun such as Glassfish, Netbeans 6 and JavaFX. Also, if you think the Nintendo Wii is too boring, check out Project Sun Spot.

Also, I need to check out Open Solaris – They showed, how you can natively run various VMs in it (such as Windows, Linux etc.). Another cool feature is ZFS

The first presentation I attended was “A Rich Application Platform: Java FX”. It looks promising not just for writing Flash replacement web applications but also for simplifying Swing development. However there are still a few missing pieces, the biggest being the lack of a modular JVM. However SUN said that the modular JVM may be released by May/June 2008. Lastly the speaker talked about the Java FX platform which is basically an operating system for mobile phones and using JavaFX for the UI.

I wonder how it compares to Google’s Android.

Next I went to the SOA and OpenESB presentation which talked about BPEL, OpenESB and JBI. OpenESB’s tool support using Netbeans 6 looked really slick. I have to check that one out. The BPEL designer actually looked quite a bit better than JBoss’ offering (visually)

The I went to the “Filthy Rich Clients” presentation which showed you best practices approaches when using Swing. The presentation talked about how to create effects in Swing and what the new Timing Framework is all about. All the talking about the cool stuff you can do with Swing makes me want to do a little Swing project…The corresponding book might be a good buy.
Next was the presentation titled “Java SE 6 Top 10 Features and Java SE7”. The presentation talked about all major new features in Java 6 such as the script engine support, support for webservices, GUI improvements (I like the built-in support for Splash screens) and the SwingWorker support.

One feature, that looked quite intriguing were the Troubleshooting Tools of Java 6.

The next talk was all about Dojo. The widgets are nice but for straight server calls I do prefer DWR instead of hand-coding some JSon structures. Unfortunately, the presentation did not mention DWR once. Nevertheless, it will be interesting to see what happens since DWR joined the Dojo Foundation.

The last presentation of the conference compared a Java EE application, a Seam application and a Spring application to each other using JPA and JSF. All three applications implemented the same feature set.

That was it – Afterward Sun provided free beer and wine and I spent a little bit more time networking before heading back home…writing this blog.

Thursday, January 10, 2008

Renewable Energy – Falling behind…

Over the holidays my wife and I spent two weeks in Germany. We stayed with my family in a small suburban town east of Berlin. Roughly once every year I get a chance to go back ‘home’. Usually not too many things change from year to year. But this year I got amazed of how mainstream solar energy is getting these days even for ordinary people.

Basically every new home construction is installing at least Solar thermal collectors. These collectors basically use the Sun to heat up water. This can be used to generate a good portion of your home’s warm water needs. You can furthermore use it for powering your floor heating system (This is really nice). But you also see quite a few homes (new and old) being equipped with photovoltaic panels which are used to convert solar energy to electricity. All this is in addition to all those countless wind mills you see everywhere while driving across the countryside.

Well, I live in Atlanta, GA and I cannot remember having ever seen solar panels here that are used for residential purposes (Please let me know if you know of some). I know that there are some promising developments going on in California (e.g. Google), Oregon and Washington. Furthermore we have some promising environmental groups here in Atlanta such as the Southface Energy Institute. However notwithstanding, I feel that the country as a whole is falling behind compared to many European countries when talking about renewable energy. We must do better, much better.

Especially, here in the southeastern United States solar energy should be a no-brainer. Take Atlanta - It is on the same latitudes as North Africa and we get plenty of sunshine here.

Labels: ,