-->
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: inheritance with MappedSuperclass
PostPosted: Fri Apr 13, 2007 3:15 pm 
Regular
Regular

Joined: Sat May 20, 2006 3:49 am
Posts: 78
Hello!

I try to generate my POJOS from my database with the reverse engineering tools. Then I try to extend the generated POJOS with my own classes to add some functionallity.

Here is an example of a generated POJO:
Code:
@MappedSuperclass
@Table(name = "ADDRESS")
public abstract class AddressEntity extends Base implements
   java.io.Serializable {

    protected AppUser appUser;

    protected SocialInsurance socialInsurance;
...


And here is an example of an inherited POJO:
Code:
@Entity
@Table(name = "ADDRESS")
public class Address extends AddressEntity {

    private static final long serialVersionUID = 1L;
   
    /**
//extra methods
...


all my hibernate generated pojos have the postfix 'Entity'. In my application I would like use always the inherited POJOs, this means the generated POJOs should not be visisble to the programmers, only to the classes which inherit the generated pojos.

all the generated pojos uses the inherited classes, this means in the above example I use AppUser, and not AppUserEntity.

Now my goal is to put all the hibernate specific annotations into the generated class, e.a. @Table. Is that possible? I always get an error if I move the @Table annotation to the generated pojo.

any ideas how to make an inheritance for my pojos to get the following:

POJOEntity - generated with Hibernate Tools, holds all hibernate specific annotations.
POJO extends POJOEntity - only @Transient methods

regards,
christoph.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 16, 2007 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you can't, @Table has to be on the entity class

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 16, 2007 2:40 pm 
Regular
Regular

Joined: Sat May 20, 2006 3:49 am
Posts: 78
is there a best practise for POJO inheritance available? I don't think that I'm the first hibernate user who needs this ... but I can't find anything in this forum.


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.