-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Commiting a transient and assigning compound primary key
PostPosted: Thu Dec 21, 2006 6:37 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
I am using compound primary keys for my POJOs which means I must explictly assign a value to it. I want to set up a listener so that this will be done automatically.

I know there are annotations @PrePersist, @PreUpdate which will receive events. However these are called for ever persist or commit for the POJO. I only need to assign the compound key once and only once not every time it is persisted or updated. I could use these annotations and include an if statement but I would of thought this is a common problem for compound primary keys so there must be a cleaner solution.

I was wondering does anyone know a smarter way of doing it?
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 4:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
if a listener can do it, I guess a custom id generator might be cleaner

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 9:04 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Thanks for that, do you have link where I can get a good example of this.
I have checked the JDoc and Java Persistence with Hibernate (Gavin King, Manning) and can't find a good example.
I am a bit confused as to how to go about what you say, anybody with any links it would be greatly appreciated.
Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 11:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
no link in mind

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 29, 2007 5:40 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Ok, thanks for getting back, I'll create a new thread looking for info on this if that's ok.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.