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.  [ 3 posts ] 
Author Message
 Post subject: Extending a annotaded class
PostPosted: Wed May 23, 2007 8:38 am 
Newbie

Joined: Tue Aug 16, 2005 9:21 am
Posts: 12
hi,

I'm facing the following problem: All my mapped objects extend an abstract class, and some of them has a kind of template classes, well, I'd like to know if I could put some annotations on these templates. I`ve tried, but the hibernate doesn`t get these annotations.

Is there some annotation to "say" to hibernate to get the annotations in the super class? Or another solution.

Code:
@Entity
public abstract class Base<T extends Serializable> implements 
      Serializable {
   private T id = null;
   ...
   @Id
   public T getId() {
     return id;
   }
   ...
}

@Table(name = "company")
public class Company extends Base<Integer> {
   private String name = null;
   @Column(length = 40)
   public String getName() {
      return name;
   }
...
}


Best regards,
Rodrigo Souza
Brazil - SP


Top
 Profile  
 
 Post subject: Extending a annotaded class
PostPosted: Wed May 23, 2007 11:47 am 
Newbie

Joined: Wed Jan 10, 2007 3:07 pm
Posts: 8
I don't know if this will be much of a help. I'm struggling with getting a handle on annotations myself. But instead of @Entity on your base class, I think you should try @EmbeddableSuperclass

We also use a common base class for all our persistent classes, and it is annotated like this

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;
    ...
}

@Entity(access = AccessType.FIELD)
@Table(name = "rio_query")
public class Interrogation extends PersistentObject
{
    ...
}



I think this might be like what you're trying to accomplish.

regards,
Dave


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 1:29 pm 
Newbie

Joined: Tue Aug 16, 2005 9:21 am
Posts: 12
Thanks Dave, it works! with a little adjust, annotation @EmbeddableSuperclass was replaced by @MappedSuperclass
This tip help me a lot!

http://java.sun.com/javaee/5/docs/api/javax/persistence/MappedSuperclass.html

Big hug
Rodrigo G. Tavares de Souza
Brazil - SP


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