-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to override a base class annotation for Id generation?
PostPosted: Tue May 22, 2007 11:57 am 
Newbie

Joined: Wed Jan 10, 2007 3:07 pm
Posts: 8
I'm not too strong with annotations, and have very little experience with them in Hibernate although they are used extensively in my current project. I have a situation where I need to change the Id Generator in a subclass.

All our persistent classes extend PersistentClass which has an id property defined thusly:
Code:
@EmbeddableSuperclass(access = AccessType.FIELD)
public abstract class PersistentObject implements Serializable
{
    @Id(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name = "oid", length=32)
    private String oid;



I now have a subclass (Interrogation) that requires that the oid be constructed from various bits of data. How can I specify that a custom Id Generator is to be used for this class? Will the custom generator have access to the object for which it is generating and Id?


Top
 Profile  
 
 Post subject: How to override a base class annotation for Id generation?
PostPosted: Thu May 24, 2007 7:14 am 
Newbie

Joined: Wed Jan 10, 2007 3:07 pm
Posts: 8
I guess this can't be done?

I've tried a number of things, with no luck. I suppose I need to break the inheritance relationship between Interrogation and PersistentObject. I'll have to duplicate much of PersistentObject in Interrogation, but I will be able to specify that ids are assigned.

Is this the only solution to this problem? I'm not really pleased with it because of violating the DRY principle, and because breaking the inheritance relationship *could* have other implications that I just don't see at the moment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.