Arnljot.com

Archive for December 14th, 2006

Aha - Hibernate and composite keys

by arnljot on Dec.14, 2006, under java

This is old news to most people I guess. But I’m currently working with a legacy database where I can’t just go and do a “alter table” statement and introduce “@hibernate.version” or something to get saveOrUpdate() to work in the session.

Currently all operations created an insert…

So this is what I finally read on the topic(7.4. Components as composite identifiers):

You may instead implement Interceptor.isUnsaved() if you wish to use saveOrUpdate() or cascading save / update. As an alternative, you may also set the unsaved-value attribute on a (or ) element to specify a value that indicates a new transient instance. In this case, the version of the entity is used instead of the (assigned) identifier and you don’t have to implement Interceptor.isUnsaved() yourself.

So! A slight change in the persistance layer, and I think I’ll be fine :)

Leave a Comment more...

Wishlist

by arnljot on Dec.14, 2006, under other

As it’s soon christmas, I’ll help out my family and girlfriend: Here is my wishlist, the kind of things one can find at Amazon.co.uk :)

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!