Hibernate3 Alpha is ready!

That’s right, the new major rev to Hibernate is ready to download (an alpha of it, at least). Check out the road map and changelog for the release.

All in all, it looks like a reasonabyl exciting release – it fills in many of the gaps in varieties of mapping, and adds some convenience functionality. This is excellent since, when I began using Hibernate, many of these things were dismissed as unnecessary. Sometimes it is recognized as being “for marketing purposes”, which I take to mean that they probably would advise against it, but too many people ask for it to leave the features out. Since the whole ORM thing is often predicated on the developers’ inability to control the database schema, I’m very glad to hear this.

It is also promising that the Hibernate team has demonstrated that they will be actively enhancing and maintaining this software. I’ve seen too many other major projects hit a certain point and then just stagnate. Great work, Hibernate team!


Worst Olympic "Sport" Yet

Feel free to suggest your own, but I nominate trampolining.

I was amazed tonight to see that there was an event based on jumping on a trampoline. 10 hops and a variety of acrobatics later, the judges spit out a subjective score and someone wins. I couldn’t help but snicker at the thought of Adam Corrolla proclaiming, “And now time for girls jumping on trampolines” at the conclusion of “The Man Show”.

I don’t know what flavor of nutcases are in charge of the Olympics. They’re clearly quite odd, picking their pet sports and finding ways to have more of the same. It’s like hey, there’s not enough aquatic events, let’s have them swim 10 different distances, and add synchronized diving just for giggles. And there’s not enough gymnastics (yeah right), if we put them on trampolines, we can have more gymnastics, but call it a new “sport”.

What a bunch of elitist jerks. Bring back the tug-o-war as an event. Add some additional team sports such as Rugby or Football. Sure, they’re not hugely popular worldwide, but when was the last time you went to an exhibition of acrobatic trampoline jumping? In any country in the world? If the Olympic officials actually liked basketball, you’d have half-court and full-court basketball on 8, 10, and 12 foot rims. Instead, we get individual and group competitions in 5 different gymnastic events, then add-on events like the dances with props like ribbons & balls, this trampoline thing, and several dozen swimming and foot race events. It’s only a matter of time before they add synchronized underwater weightlifting.

It will be over soon, and the NFL will mean something soon, and the college football debates can begin. In the mean time, there’s always Olympic beach volleyball.


ACC Title Game – Jacksonville

The decision has been made, the 2004 & 2005 Atlantic Coast Conference football championship games will be in Jacksonville, beating out Baltimore, Charlotte, Miami, Orlando, Tampa and Washington.

While I would have loved Atlanta as the location, the SEC title game precludes that option, so Jacksonville truly seems to be the next best option. Washington and Baltimore are too far north, too far from the middle of the conference, too cold in early December. Miami, Orlando, and Tampa are all too far south, a 10+ hour drive from anywhere but FSU, Miami, and Georgia Tech (though Tampa wouldn’t be bad because a) no ACC Bowls are played there, b) great facilities, and c) my mom and in-laws live there). Charlotte isn’t a bad option – a nice town, and nice facilities, but in the run-up to the bowls, fans and players want an atmosphere to be outside, celebrate, and maybe take a vacation. I mean, do you think of the great atmosphere surrounding the Motor City Bowl? Charlotte also would have let the Carolina schools think they’re still in charge, and would be a bad thing.

That leaves Jacksonville. Decent facilities, decent town (from what I hear). It’s already the site of a game with HUGE atmosphere (Florida/Georgia), that is wildly successful. The biggest flaw in J-ville is that the ACC’s #2 bowl is the Gator Bowl, and few fans will want to go to the same town twice in a month. So I suppose they’re betting that the #2 team will make a BCS bowl, now that they’ve added the 5th game. Not a bad bet, with the ACC jostling for the crown of the best conference in all the land, it’s a reasonable bet. If not, a swap with the Capital One or Cotton Bowl could make sense, and the Peach Bowl is one of the top tier #3 bowls around. And for the near future, chances are that either FSU or Miami will be in that game, so the location ensures a huge turnout. Not a bad decision from the new ACC… at least until they prove to Atlanta that it’s worth their while to give the SEC title game the boot.


Hibernate Tip – Session Closing for Large Imports

We recently moved from the poor session-per-sql-statement approach to Hibernate to the open session in view approach, complete with thread local handling of the session. (Yes, I know I could use Spring.) We do have some large, legacy import jobs that we have been migrating, and they were opening the session at the beginning, importing 40,000 records, and closing the session. At least we were trying.

As best I can figure it, Hibernate’s session cache isn’t limited in size or objects (at least by default). So the import would start strong, slow down, slow to a crawl, and then pretty much kill the server, requiring a reboot (of RedHat). So by never closing the session, we were causing the session cache to grow to occupy most of the system’s memory.

Since the cache really wasn’t doing us any good, I decided to try closing the session after each record was processed. This changed the performance dramatically. The import went from taking days to run and crashing about 2/3rds of the way through to completing in a couple of hours. While this discovery isn’t earth-shattering, I thought that I’d put this tip out there in case someone else runs into similar problems.

For most tasks, allowing several queries worth of data to accumulate in the session cache is likely harmless and probably helpful, but be aware of its impact on large jobs.


Invent your own java.lang Class

NoClassDefFoundError: java.lang.nmpcJackets


That message greeted me as I attempted to start Compuware’s DevPartner J today. So I look at my JDK 1.4 class reference. Not there. Didn’t think it was. Googled it. 2 results – both related to one FAQ from Compuware.

So apparently they wrote a class that’s required for their product, and then called it a java.lang class! Novel idea – call it com.compuware.devpartner..nmpcJackets. That way, users that see this error will realize it’s a problem with the product configuration instead of thinking that something obscure has gone heinously wrong with their JDK. Ridiculous.


Socialism is Evil

Walter Williams has a couple of solid articles about Free Health Care and Socialism in general. This article on the (lack of a) car insurance crisis is an amusing read as well. Although critics of my last blurb on free health care would have you believe that I am heartless, soulless, and greedy, Williams strikes a chord with me when he says, “Reaching into one’s own pocket to assist his fellow man is noble and worthy of praise. Reaching into another person’s pocket to assist one’s fellow man is despicable and worthy of condemnation.”

I’m not averse to charity. I am in favor of charity, and give with a glad heart. I have been blessed, and my Christian faith lights a fire in me to give back from that blessing. It’s not that I don’t want to enrich and enable those who have fallen on hard times, it’s that I don’t think the government is the proper venue for it. It’s that programs like this focus on symptoms, and perpetuate them. Poverty is not caused by a lack of money. A lack of health care isn’t the problem, it’s the lack of means to get health care that’s the problem. This breaks down into employability and affordability. Reforms are needed to make health care more affordable – government CAN accomplish this. Assistance is needed to prepare people to find employment that will either provide health care or pay enough that they can afford health care. Private charities can accomplish this far better than monolithic government programs.

Williams mentions corporate handouts as wrong in the same vein, and I agree fully with him. Taking money from one group and handing it to another is immoral, and often degenerates into buying votes (BOTH parties do this, sadly). If you have such a burden for the plight of certain people in certain circumstances, open up your wallet and give. I’ll do the same.


Tapestry in Atlanta Tonight

Howard Lewis Ship will be presenting on Tapestry tonight at the Atlanta Java Users Group meeting, details here. Wish I could be there – between my wife’s work function that requires spouse, and my birthday being today, I’m not gonna make it.

It looks like Erik Hatcher will be presenting on it at the Atlanta Java Software Symposium, so I can catch up on it there, though I may only attend the first half to attend the session on JSR-175 Metadata or Groovy.


Hibernate Lightweight Class Wrinkles

Sometimes, in Hibernate, the need arises to load part of an object sometimes, and all of it the rest of the time. In that vein, the Lightweight Class pattern is detailed, allowing you to map both a lightweight version of a class and a heavier version.

Now you may cite the often mentioned issue of whether there is a significant performance difference between a small projection and a select(*). In this case, understand that we have little, if any control over our database schema. In this case, realize that the table has about 80 columns, and for some queries that may return hundreds of results, we really only need 2-5 of these columns. There is a performance difference in this extreme case.

This was all well and good, until we discovered a major issue that was causing our lightweight class not to work when we had both the lightweight and heavyweight versions mapped in a many-to-one relationship to a parent class. The problem is based on the fact that Hibernate uses the table name (not the object name) for uniqueness, so when we eagerly fetched the summary object, Hibernate attempted to resolve the detail object in its session cache. Because the summary object has been loaded, the cache will hit for the detail object, and Hibernate will attempt to put the summary object into the detail field, causing some CGLIB class cast issues.

There are a couple of solutions to this. One is a hack, but effective enough – change the table name for one of the classes to be of a different case (one upper case, one lower case) – the uniqueness is based on a case-sensitive table name, so the session cache won’t it. Alternately, Gavin recommends extending EntityPersister, overriding getIdentifierSpace(), and specifying <class persister=”MyPersister”/>.

Both will work. My additional tips on getting lightweight class to work are here (to be used with the Hibernate documentation on the pattern). It looks like a change in a future version of Hibernate (possibly 2.1.7, certainly 3.0) will make this a non-issue, with uniqueness based on persistent class instead of table name. In the mean time, I hope this is helpful.