[BEGIN nerdity]
I think I'm gonna keep ranting on Hibernate's claim of "removing metadata hell" until I die.
Let's say I create a class, a ListEntry. It's very simple. Dutifully, I create an ORM mapping file for it. Fields of entryID, addTime, completedTime, userID, and entryText (for now). These map fine.
I also create a class, User. I dutifully create an ORM mapping file for User.class, too (userID, email, registrationTime, cryptPW, firstName, lastName, registrationKey).
Now, the User objects have a one-to-many relationship to ListEntry. Several ListEntries on a User. So there is a method/field on the User: Map[Long,ListEntry] entryMap.
Hibernate, in theory, has this bad-ass thing. I just add to the User.class mapping a couple of lines saying, "it has a field, entryMap, and it gets filled with ListEntry objects from the DB that have the same userID as the user."
Now, you would think that it would know that when I say "this map contains ListEntry objects" that it would do something intelligent. Like, oh, maybe go to the ListEntry ORM map and get the mapping from there.
But no! It doesn't do that. I have to *replicate* almost verbatim the information in the ListEntry ORM file into the User ORM file - thus *doubling* the amount of metadata I need to keep track of for one class (and correspondingly increasing the likelihood of version drift).
Irritating.
[TANGENT]
Astute readers may notice that the fields above are things like "addTime" and not "addDate". This, too, is a nice irritating thing about Hibernate. I, like any reasonable nerd (and I haven't met a Java programmer who thinks different), store dates in the database as longs/BIGINTS and turn them into Dates on the way out (setAddDate(new Date(rs.getLong("addDate")))).
However, Hibernate will only automagically map Date objects into DATE or TIMESTAMP datatypes. Thus, I must create separate fields for those (addTime()) and then convert to Dates on demand.
Seriously. Who the fuck stores Date objects in what could be non-portable datatypes? For that matter, what idiot actually uses java.sql.Date? Too many heartaches and broken bones with that lot, mate. You can play with Calendar all you want and God have mercy on your soul as you do.
[/TANGENT]
[END nerdity]
I think I'm gonna keep ranting on Hibernate's claim of "removing metadata hell" until I die.
Let's say I create a class, a ListEntry. It's very simple. Dutifully, I create an ORM mapping file for it. Fields of entryID, addTime, completedTime, userID, and entryText (for now). These map fine.
I also create a class, User. I dutifully create an ORM mapping file for User.class, too (userID, email, registrationTime, cryptPW, firstName, lastName, registrationKey).
Now, the User objects have a one-to-many relationship to ListEntry. Several ListEntries on a User. So there is a method/field on the User: Map[Long,ListEntry] entryMap.
Hibernate, in theory, has this bad-ass thing. I just add to the User.class mapping a couple of lines saying, "it has a field, entryMap, and it gets filled with ListEntry objects from the DB that have the same userID as the user."
Now, you would think that it would know that when I say "this map contains ListEntry objects" that it would do something intelligent. Like, oh, maybe go to the ListEntry ORM map and get the mapping from there.
But no! It doesn't do that. I have to *replicate* almost verbatim the information in the ListEntry ORM file into the User ORM file - thus *doubling* the amount of metadata I need to keep track of for one class (and correspondingly increasing the likelihood of version drift).
Irritating.
[TANGENT]
Astute readers may notice that the fields above are things like "addTime" and not "addDate". This, too, is a nice irritating thing about Hibernate. I, like any reasonable nerd (and I haven't met a Java programmer who thinks different), store dates in the database as longs/BIGINTS and turn them into Dates on the way out (setAddDate(new Date(rs.getLong("addDate")))).
However, Hibernate will only automagically map Date objects into DATE or TIMESTAMP datatypes. Thus, I must create separate fields for those (addTime()) and then convert to Dates on demand.
Seriously. Who the fuck stores Date objects in what could be non-portable datatypes? For that matter, what idiot actually uses java.sql.Date? Too many heartaches and broken bones with that lot, mate. You can play with Calendar all you want and God have mercy on your soul as you do.
[/TANGENT]
[END nerdity]

Comments
Sorry you're mired in it. :-(