-->
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 does one map fields in a DomainObject base class?
PostPosted: Wed Aug 26, 2009 5:27 pm 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
How does one map fields in a DomainObject base class using annotations? I'd really like it if Hibernate could inherit the @Id, etc. annotations in all the subclasses, because DomainObject is really very good at defining a quick and dirty equals, as well as some convenience methods like isTransient and stuff like that. If nothing else, I need id and isActive on every domain object in the system, so it makes sense to have a base class for this. I obviously do not want to put @Entity on DomainObject, because this is not a subclass relationship.

Help?


Top
 Profile  
 
 Post subject: Re: How does one map fields in a DomainObject base class?
PostPosted: Wed Aug 26, 2009 9:34 pm 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
Okay, this is what I have so far:

Code:
@MappedSuperclass
public abstract class DomainObject implements Serializable {

   /* Members */
   @Id
   @GeneratedValue
   protected Long id;

   @Column( name = "is_active" )
   protected boolean isActive = true;
...
}


I realized that using @MappedSuperclass will inherit these fields, which is great!

HOWEVER, now I have a problem with the name of the id that gets generated for SubClass (of DomainObject)

Code:
Repeated column in mapping for entity: company.domain.SubClass column: id (should be mapped with insert="false" update="false")


Any ideas?


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.