Happenings

Jdbc and Enums

After months of using JPA/Hibernate almost exclusively, I got caught out on a relatively simple bug when using JDBC more directly (well, via Spring’s JdbcTemplate):

public List<SomeObject> fetchSomeObjects(RecordType recordType) {
  Map<String,Object> params = ...//Map creation;
  params.put("recordType", recordType);
  return namedParameterJdbcTemplate.query("select * from someObject where recordType =  :recordType",
    params,
    someRowMapper);
}

That was from memory, so it may be a little off, but it should give you the basics of what the code was doing. It looks okay to my eyes, but, of course, it wasn’t. When run an exception was being thrown from the bowels of the JDBC code saying that RecordType couldn’t be converted to a JAVA_OBJECT.

Odd, I thought. It had worked perfectly well with an in-memory database (HSQL) but now wasn’t working when deployed on a hosted database (SQL server).

I couldn’t spot it straight away, so a quick debugging session revealed the problem: JDBC doesn’t play nicely with enums. RecordType, an enum, was being passed to JDBC verbatim without any attempt for it to match up with the recordType column (a varchar column); and that just doesn’t work. You need to explicitly convert from an enum to a String.

Thankfully, it was a one-line fix:

params.put("recordType", recordType.toString());

It doesn’t read quite as neatly but it works. The fact that the original version reads quite well (the value for “recordType” is called recordType) actually makes the bug harder to spot. Now, back to JPA.

Film Fight 2011: January

It’s 2011 and time for a new Film Fight. I’ve been considering changing the format this year, but have decided against that for now so it’ll be the usual: a paragraph or so for each film, with the best selected as the month’s winner. All the winners are compared, and the year’s film is selected. Easy.

January is always a packed month, with Oscar-baiting meaning that the quality is kept suitably high. In January 2011, there are six movies to be reviewed.

First up, is It’s Kind of a Funny Story: an indie film that tries to show how mental illness can affect anyone and is easily misunderstood by non-sufferers, by taking a slightly comedic look at the issues. It doesn’t go far enough in it’s exploration of the issues, often opting for shorthand and stereotypes to make it’s points, which is somewhat disappointing. It does, however, move the plot forward at a good pace, balancing comedic elements (Zach Galifianakis plays a big part, but more does so more seriously than usual) and a romantic subplot with relative ease. It’s not a classic, but it’s a good, kind-hearted film. (See my It’s Kind of a Funny Story Twitter review).

The King’s Speech humanises King George VI in a way I hadn’t thought possible. By focussing purely on his speech impediment and his years of suffering and humiliation because of it, we begin to see him as a sympathetic man, rather than purely as an elite Royal. He is, of course, both, and it’s to the filmmaker’s credit that they manage to get this across so clearly. This is successful in large part due to Colin Firth’s fantastic performance; the crushed dignity of the soon to be king made clear in every embarrassed look and stammer. An excellent film. (See my The King’s Speech Twitter review).

Blue Valentine is almost an anti-love story. It doesn’t focus on things being difficult and then working out. No, instead it contrasts the beginning and end of a relationship, showing a couple at their worst. Communication break downs at the end of a marriage are intercut with two younger versions of the leads with hope and kindness trying to find their place. It’s sad and well-done, if a little slow. It does a remarkable job of showing how people change. Worth seeing. (See my Blue Valentine Twitter review).

127 Hours does some unexpected things, not least of all because of what everyone expects from the premise: a climber (played by James Franco) is trapped by a boulder against his arm in a cave and, over several days, is forced to make a very difficult decision. Despite being on his own, and their being relatively little dialogue, Franco brings out an extremely likeable character that you want to get out of this hopeless situation. Every tiny triumph and minute failure will see you gasp in just the right way. When the inevitable happens, the film has really earned it’s most painful moment. A few moments aside, this is a very good film. (See my 127 Hours Twitter review).

Darren Aronofsky has another classic on his hands with Black Swan, the tale of seeking out perfection when the pursuit itself makes perfection much more difficult. Natalie Portman is excellent as a ballerina who practices obsessively, even when her obsession – her madness – stops her from seeing the world correctly. It’s surreal, dark, sensual and unnerving: we’re never allowed to know how much of what we see is real and what is imagined. I won’t spoil it, but the ending is excellent: finding the right mix of closure and mystery to round out an altogether astounding movie. Very worthwhile. (See my Black Swan Twitter review).

Finally, NEDs shows how one young boy is repeatedly failed by those in authority around him, forcing him down the path he’s been trying to avoid for years. We see his fall into violence and crime, despite his brightness, and can imagine how it could have been avoided if people had acted with a little more kindness and less judgement. NEDs, then, is a morality tale; a look a reaping what we sow and then blaming the crops for withering. Brutal in places, but a stunning watch. Very good. (See my NEDs Twitter review).

As I mentioned in my preface, there are a number of good films this month. Five of the six would easily have won in other months (and the sixth, It’s Kind of a Funny Story, would’ve done well in some). If forced to watch just one again, I’d pick Black Swan; and that’s why it’s the first winner for 2011.

Film Fight 2010: Finale

As always my caveat from previous years still apply: Film Fight is a knock-out tournament and, as such, will only select my favourite film. It makes no guarantees about any other place.

First, good films that didn’t win their month:

  • Up In The Air
  • A Prophet
  • Precious
  • Shutter Island
  • Kick-Ass
  • Green Zone
  • Predators
  • Toy Story 3
  • Scott Pilgrim Vs The World
  • Cyrus
  • The Other Guys
  • Winter’s Bone
  • The Social Network

And then the monthly finalists:

  • January: The Road
  • February: A Single Man
  • March: Crazy Heart
  • April: Crying With Laughter
  • May: Four Lions
  • June: Rec 2
  • July: Inception
  • August: The Expendables
  • September: Dog Pound
  • October: The Town
  • November: Let Me In
  • December: Megamind

Last year had a number of really strong contenders as finalists, with only one film sneaking through. Sadly, that’s not the case with Let Me In, The Expendables, and Rec 2 all getting through when they might not have in another month (possibly Megamind too, but it’s fun).

That said, there are still a number of very strong choices in there. I’d strongly recommend the rest, but need to pick out a few.

4th place goes to Crying With Laughter, for it’s dark comedy and bleak look at one man’s life.

3rd place goes to Dog Pound: it’s such a well-paced film, constantly raising the feeling of menace until the final act unleashes it all at once.

2nd place: I’ve debated back and forward on this and the first place a few times. I’ve even switched them around in various drafts of this post, it’s that close. I think, though, that the second place goes to Inception. While many will get stuck on the special effects, which are quite extraordinary, it’s the storytelling structure that is the real key to this film. Multiple stories, in multiple timeframes, all happening at the same time and interacting with each other; and rarely missing a beat. That’s an accomplishment on it’s own. The fact that multiple viewings reveal more, and there are many more stories left untold leave this as a real masterclass in structure.

1st Place: That means that The Road is the Film Fight winner for 2010. It’s bleak, agonising, and quite desolate, but such a strong vision of a world where a man is compelled to protect the only thing that matters to him, his son, and the consequences of being so single-minded. A classic.

Film Fight 2010: December

As is normal at this time of year, there’s not much out that looks worthwhile so I’ve only seen a few films this month.

First up, Megamind is the superhero story we’ve all wanted to see for a while: the one where the evil villain and his dastardly creations finally win out and defeat the hero. Megamind is about the loneliness of a villain with no hero to fight. From that point onwards, the story is fairly predictable but fun, built around a number of parodies and sight gags. The highlight is probably Will Ferrell’s Marlon Brando impersonation, but there are a bunch of other neat little moments. It never manages to raise itself to the level of a classic animated film (like Toy Story 3), but is good enough to watch at least once. (See my Megamind Twitter review).

The Tourist, however, is not good enough to recommend watching even half of it. It’s a truly terrible film on almost every level. It looks pretty and has a strong cast, but they’re squandered here on terrible dialogue and a formulaic, “twisting” plot. You’ll see the twists coming, you’ll cringe at the ropey lines, the heavy-handed spoonfeeding of information, the seen-it-all-before action set pieces, and the overacting. I can’t recommend this at all. Terrible. (see my The Tourist Twitter review).

The winner is Megamind. Not because it’s a classic film, more because it didn’t have any competition.

Film Fight 2010: November

For various reason, I only made it to the cinema once, so the winner is a foregone conclusion.

Let Me In is an American remake of the classic Swedish film, Let The Right One in. During the making of this film, we were promised that it would be a different take on the source, focussing more closely on the burgeoning relationship between Oskar and Eli (renamed Owen and Abby), and the relationship between Eli and her carer. This remake fails to deliver. What we get appears to be a somewhat neutered cut of the director’s vision: following the plot of the original very closely, sometimes shot for shot, but replacing the uneasy menace with some more obvious action scenes. There are moments where it shines. The few moments that Richard Jenkins gets he puts to great use, especially the scene he’s hiding in a car. Largely, though, it’s disappointingly similar to the original, without many fresh ideas. (See my Let Me In Twitter review).

In another month it wouldn’t have gotten through, but Let Me In is obviously the November winner.