Monday, November 19, 2007

What I want to do coming year?

I have been bored programming dear old enterprise applications lately, so I am seriously thinking of doing something new and more intellectual than writing data-driven applications.

I'm thinking of doing something significant coming year; while it would be pretty tough to stick to it all year along, I would at least want to build a strong tooling around, barely known, Felix language. Felix, compiler is written in OCaml, seems to be an interesting procedural/functional scripting language. In coming months I want to build an IDE for Felix using Eclipse and DLTK sub-project. There are many strong motivations for me to start this off apart from working on something intellectually stimulating and looking DLTK from inside.

I have just downloaded sources for OCaml, Python and Felix and compiling them to get started. As of now there's no progress and I'm yet to learn python, Objective Caml, Felix and DLTK itself, but I'm sure it would be a lot of fun.

While compiling OCaml on Ubuntu 7.10 I got this error
/usr/bin/ld: crt1.o: No such file: No such file or directory
and thanks to this guy for reminding that I'm not just Ubuntu user but a developer as well and would need libc-dev for just about everything :).

I'm looking forward to creating something interesting.

Tuesday, November 13, 2007

Hibernate won't delete child objects from database

Given a commonly known parent/child relationship in a domain model, the hibernate code below would not delete child object from database.
Parent p = (Parent)session.load(Parent.class, id);
Child c = p.getChildren(0);
Unless you have specified 'all-delete-orphan' as the cascade value in the relation as shown below, or use 'Session' object to delete the object from db.
<set name="children" inverse="true" cascade="all,delete-orphan">
<key column="parent_id">
<one-to-many class="Child">
This detail is from hibernate manual (Section 21.3), and I have read it many times in last three years, but somehow I didn't find it intuitive thing to do and hence drawing a blank.

It's a breeze to have 'Session' object available everywhere in the code, but imagine a pile of layers hiding everything related to persistence, all you can do is play around with associative object references in the object graph.

There are many such minute intricacies in Hibernate which give surprises (and pain if that code is not covered by test cases), Endless debugging with hibernate is just as painful as dear old CMP (Container managed persistence in Entity Beans). Ironically though, Hibernate can win the "paingiving" if you use it with cglib whereby, while debugging, you see weird things in lazily loaded proxy (or object zombie if you like to call it so) where you wanted to see only a string value.

And oh I hate that with it's 4000 lines of code...