Hibernate: the sequel

February 13th, 2003

I encountered my first mayor stumble in getting Hibernate to do what I want it to do.

We have a database which has business data as primary keys. Those keys are (wisely) encapsulated in objects (in the Java code, that is). Now, Hibernate recommends not to use business data as primary keys, but says it still is allowed. I'm glad to hear that. Now I'm just figuring out how to tell Hibernate that it should use our class while doing the mapping. I already found out that it had to implement UserType. But the documentation of the UserType interface seems to be a bit scarce in what exactly every method is doing. So now I'm stuck with a

cirrus.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of X
I hope I can get this solved soon. Refactoring the DB to use non-business primary keys is too big an investment for us ATM (certainly in the light of the fact that we're still evaluating Hibernate, and didn't take the "let's do it" decision yet).

2 Responses to “Hibernate: the sequel”

  1. Gavin Says:
    You don't need a UserType for this very standard thing. You use a mapping instead.
  2. Gavin Says:
    Woops! The above is meant to read: a <composite-id> mapping

Leave a Reply