-->
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: POJO subclassing of annotations does not propogate to DB
PostPosted: Wed Nov 29, 2006 8:25 pm 
Newbie

Joined: Wed Nov 29, 2006 8:13 pm
Posts: 8
I'm new to Hibernate and annotations. I've created a few persistent POJOs that extend from an abstract class which in itself contains id and timestamp properties. The abstract and concrete class looks like this:

public abstract class AbstractPOJO {
protected long id;
protected Date timestamp;

@Id
public long getId() {
return id;
}

@Column(name="timestamp")
public Date getTimestamp() {
return timestamp;
}

// corresponding setter methods
}


@Entity
@Table(name="P_POJO")
public class PersistentPOJO extends AbstractPOJO {
protected String name;

@Column(name="pojo_name")
public String getName() {
return name;
}

// corresponding setter methods
}


Now when I have hibernate create the DB schema for me, it creates the P_POJO table with the "pojo_name" column but no timestamp or id columns. Is there a way to have hibernate also create the superclass's columns as well, or must I scrap the abstract class and copy/paste the id and timestamp properties in each persistent POJO? I would hate to do the latter. Thanks.

--Larry


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 9:12 pm 
Newbie

Joined: Wed Nov 29, 2006 8:13 pm
Posts: 8
nevermind-- I totally forgot about @MappedSuperclass!


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.