Earlier this week I ran into a missing feature in the Scala xml library and I ended up adding this feature myself, which turned out to be pretty simple.
I was trying to extract the text contents of an element in a piece of XML using the handy \ and \\ methods on scala.xml.NodeSeq. These methods allow you to extract sub-elements from an XML node in a way very similar to XPath, something like this:
val xml = <a><b><c>text</c></b></a> val c1 = xml \ "b" \ "c" val c2 = xml \\ "c" val text = c2.text
The problem I ran into occurred when I tried to use these methods to extract an element when one of its attributes had a certain value.
After hearing a lot about distributed source code management (SCM) systems lately, I've been playing around with GIT and I like it a lot. As a longtime user of traditional SCMs like CVS and Subversion, working with GIT is something of a revelation and so nothing seems more natural than spreading the gospel a little
To help other people learn about GIT, I've collected some of the most interesting GIT 101 stuff I've found around the net.
Filed under GIT, Tools | 13 Comments »
Last year I came back from QCon San Francisco filled with new ideas. DSLs were clearly going to rule the world so I'd better start using them any chance I got. No surprise then that I was back for more this year, hoping to find out about the hottest new bleeding edge trends. Unfortunately the first two days were slightly disappointing. I did visit some interesting cloud computing introduction talks and Kent Beck's talks were pretty funny, but nothing really blew me away.
Luckily the last day was more like it. Here are some impressions of what's hot and what's not:
- Relational databases are very uncool (or "unkuu" as Kent Beck's son would apparently put it)
- Alternative storage solutions like CouchDb, AtomServer, and Neo4J are very hot.
- Google's BigTable and MapReduce are very influential and lots of innovative new projects are based on them.
- Everything should have a RESTful API.
There were a lot of interesting sessions on friday but the best two were definitely:
- Unshackle your Domain, a DDD session that talked about some very interesting domain modeling techniques. See Erik's blog for more info on that session.
- AtomServer - The Power of Publishing for Data Distribution. These guys not only discussed a very interesting RESTful data storage solution, they were also very entertaining and their new dating site http://www.AnyoneWillDo.com/ will undoubtedly be very successful.
All in all it was very much worth it coming to San Francisco this year and hopefully I'll be back for more inspiration next year.
Filed under Domain Driven Design, General, qcon | 4 Comments »
It seems Oracle on linux is the only way to get Oracle on my Mac.
I recently switched from Ubuntu to OS X 10.5 (Leopard) as my main development OS and I quickly ran into a major hurdle, this being the fact that there is no reliable way to install an Oracle database server on Leopard. Oracle does offer a version for OS X but they are obviously not very serious about the Mac as a platform because it is an outdated version of 10g and, more importantly, it only really runs on OS X 10.3, a version that has been outdated for almost two years. I went on a Google hunt for information on how to install this older version on my shiny new Leopard-enabled MacBook Pro and I found some forum posts and an outdated site listing the tricks for getting it to work on 10.4, the previous version of OS X, but no clear instructions for getting it to work on Leopard.
Filed under Java | 3 Comments »
We ran into a TransientObjectException in our Hibernate-enabled code. At first the exception was very hard to reproduce and only occured in very rare cases. Sometimes during our integration tests and sometimes during our smoke tests.
We tried just about everything to find out why Hibernate interpreted the relevant objects as being unsaved (ie transient) even though we verified that they were indeed saved in a previous Hibernate Session by looking at the sql logging.
It turns out that Hibernate does not see the diffference between the values "0" and "null" when looking at the ID property (a java.lang.Long) to check whether the object is persistent. Because our Oracle sequence starts at 0, the first object that was persisted had an ID of 0. When that object was then used in a later Session, Hibernate did not recognize that value as valid and interpreted the object as transient.
We fixed this by adding an extra unsaved-value attribute to the relevant mapping. Like so:
<id column="ID" name="id" type="java.lang.Long" unsaved-value="null" length="10">
<generator class="native">
<param name="sequence">MY_SEQ</param>
</generator>
</id>
That solved the problem. Whether this is a bug or a feature in Hibernate I'll leave as an exercise for the readers
Filed under Hibernate, Java | 4 Comments »