Friday, May 1, 2009

JPA composite key craziness (vs. SQL Alchemy)

I know that a framework generally isn't designed to handle edge use cases gracefully. The old saying goes that you make the common case fast and the rare case possible. That often turns out to be the case for frameworks as well.

I was trying to map a composite key that made up an Oracle view - two foreign keys. The JPA is sadly very complicated with its mapping of composite keys (hibernate doc link). I heard stories around the office like, "I think XXX tried to do one of those, but then he backed out those changes." and "I did one of those once (shudder)."

In response to my ranting, a python guru friend of mine who works on both python code and java code regularly, told me that SQL Alchemy has had support for composite keys since version 0.1. He said it's pretty simple... Too bad. Too bad the JPA standard isn't better. However, maybe now that Oracle is buying Sun, the JPA will get a shot in the arm.

No comments: